public ContactEntry createContact(String username)throws IllegalArgumentException {
// Create the entry to insert
ContactsService myService = new ContactsService("exampleCo-exampleApp-1");
try {
myService.setUserCredentials("[email protected]", "[email protected]");
} catch (AuthenticationException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
String name = "neha'sContact";
String notes = "this is some notes from gdata API client";
ContactEntry contact = new ContactEntry();
contact.setTitle(new PlainTextConstruct(name));
contact.setContent(new PlainTextConstruct(notes));
Email primaryMail = new Email();
primaryMail.setAddress("[email protected]");
primaryMail.setRel("http://schemas.google.com/g/2005#home");
primaryMail.setPrimary(true);
contact.addEmailAddress(primaryMail);
Email secondaryMail = new Email();
secondaryMail.setAddress("[email protected]");
secondaryMail.setRel("http://schemas.google.com/g/2005#work");
secondaryMail.setPrimary(false);
contact.addEmailAddress(secondaryMail);
ExtendedProperty favouriteFlower = new ExtendedProperty();
favouriteFlower.setName("favourite flower");
favouriteFlower.setValue("daisy");
contact.addExtendedProperty(favouriteFlower);
ExtendedProperty sportsProperty = new ExtendedProperty();
sportsProperty.setName("sports");
XmlBlob sportKinds = new XmlBlob();
sportKinds.setBlob(new String("<dance><salsa/><ballroom dancing/><dance/>"));
sportsProperty.setXmlBlob(sportKinds);
contact.addExtendedProperty(sportsProperty);
System.out.println(contact);
// Ask the service to insert the new entry
try{
System.out.println("Inside try Block:");
URL postUrl = new URL("https://www.google.com/m8/feeds/contacts/[email protected]/full");
System.out.println("Inside try Block1:");
return myService.insert(postUrl, contact);
}
catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
}
return contact;
}
quand je suis en utilisant ce code, il donne l'erreur suivante: [ERREUR] [simplerpc] - Ligne 9: Aucun code source est disponible pour le type com.google.gdata .data.contacts.ContactEntry; avez-vous oublié d'hériter d'un module requis?quand je suis en utilisant ce code donne erreur
Ce code est côté serveur, puis il donne également une erreur – Neha
@Neha Retournez-vous directement l'objet ContactEntry au client (GWT)? – jaxb
oui je retourne l'objet ContactEntry – Neha