October 27, 2010

Tolerado WSC APIs upgraded to support SFDC Winter’11 Web Service API changes !

Since SFDC winter’11 release, I was updating the Tolerado WSC APIs. This update to Tolerado APIs was important because Winter’11 brought too many cool enhancements to the Web service API.

List of changes done.

Following are the changes done to Tolerado WSC APIs

1. Upgraded to latest WSC-API

SFDC WSC got a new release(wsc-20.jar) few weeks back, Tolerado was upgraded to use that.

2. Upgrade to latest SFDC API v20.0 WSDLs

All WSDL2Java stuff for each partner, enterprise, metadata and apex WSDL, was regenerated to latest API version i.e. 20.0. This is important so that one can take benefit of cool new features of Web Services API like

  • Multiple Object Type Support: Ability to process records for multiple objecttypes, including custom objects, in one create() or update() call. For example, you can create a contact and an account in one call. Previously, you could only process records for one object type in a call.
  • Better Transactional Control : The New AllOrNoneHeader SOAP Header, allows the create(), delete(), undelete(), update(), and upsert() calls to roll back all changes unless all records are processed successfully. The default behavior is to allow partial success of a call.
  • Increased Number of Relationships Allowed in a SOQL Query : With Winter '11, you can include 25 relationships in a SOQL query in all API versions. Previously, there was a limit
    of 20 relationships.
  • Chatter Photos in User object:  The User object includes new fields if Chatter is enabled:
    • FullPhotoUrl—The URL for a user's profile photo.
    • SmallPhotoUrl—The URL for a thumbnail of a user's profile photo.
    • DigestFrequency—The frequency at which Salesforce.com sends the user’s Chatter personal email digest.
  • More details in Winter’11 release notes for other new and changed objects etc.

3. New Tolerado API’s for AllOrNoneHeader support

ToleradoEnterpriseStub & ToleradoPartnerStub classes are enhanced, to have a direct call to set new AllOrNone header. So one no more needs to get into native SOAP bindings to add this header. Also added Junit tests to make sure the AllOrNone SOAP header changes are working correctly.

Here is a code sample that shows how to turn on “AllOrNone” setting.

 public void testRollBackOnContacts() throws Exception {
         ToleradoPartnerStub stub = new ToleradoPartnerStub(credential);
         //
         // Create a new Contact
         //
         SObject c1 = new SObject();
         c1.setType("Contact");
         String firstName = "Abhinav";
         String lastName = "Gupta-";
         c1.setField("FirstName", firstName);
         c1.setField("LastName", lastName);

         //
         // Create a new Contact, created without last name intentionally to fail
         //
         SObject c2 = new SObject();
         c2.setType("Contact");
         c2.setField("FirstName", "Abhinav1");

         // Using AllOrNoneHeader = true, to make the rollback happen
         stub.setAllOrNoneHeader(true);

         SaveResult[] saveResults = stub.create(new SObject[] { c1, c2 });
         Assert.assertNotNull(saveResults);
         Assert.assertEquals(2, saveResults.length);
         Assert.assertEquals(false, saveResults[0].getSuccess());
         Assert.assertNull(saveResults[0].getId());
         Assert.assertEquals(false, saveResults[1].getSuccess());
         Assert.assertNull(saveResults[1].getId());
   }

One can see Junit tests for each enterprise and partner wsdl as detailed code samples.

4. Latest Tolerado-WSC available in downloads

All code changes are in SVN and latest version of all tolerado and salesforce wsdl jar files etc is available in download area.

What about Tolerado for Apache Axis ?

I have left “Tolerado for ApacheAxis” upgrade intentionally(+to save my time Winking smile) because, I personally feel we should move to SFDC-WSC APIs for all better performance. Still if anyone is blocking/depending on Tolerado for Apache Axis and wants Winter’11 coolness, please let me know. I will do that upgrade to Tolerado-Axis stubs too.