You need to sign in to do that
Don't have an account?
Updating records problem - how to use correct package?
Hi,
I'm having a hard time using the api example (http://www.salesforce.com/us/developer/docs/api/index_Left.htm#StartTopic=Content%2Fsforce_api_calls_create_saveresult.htm|SkinName=webhelp) to update Cases. The code doesn't seem to be the problem...the problem is getting access to the appropriate classes for using the SaveResult[] type. See code below.
List<SObject> cases = query("Select Id FROM Case WHERE Custon_Number__c = '" + num + "'");
case_ID = cases.get(0).getId();
Case[] updates = new Case[1]; // above SOQL call should only retrieve 1 case
Case updateCase = new Case();
updateCase.setId(case_ID);
updateCase.setCurrent_Approver__C("John Doe");
updates[0] = updateCase;
// Invoke the update call and save the results
try {
SaveResult[] saveResults = binding.update(updates[0]); // ***HERE IS THE PROBLEM*** SaveResult[] cannot be resolved
}
catch (Exception ex) {
System.out.println("An unexpected error has occurred." + ex.getMessage());
return;
}
It looks like I need to use the com.salesforce.results package...(http://www.adnsandbox.com/media/flexsdk/docs/com/salesforce/results/package-detail.html)...but am unsure of how to do that. Any advice??
Also note, I'm using my own login and the enterprise.wsdl from a DE org where I have full admin permissions. Also, used latest 2.2.8 Apache CXF for wsdl2java, and all other parts of integration work fine.
SaveResult should be generated from your from the WSDL, search the tree of files generated when you ran WSDL2Java.
I checked and SaveResultType.java is the closest. No SaveResult.java to be found. Is it because I used CXF? I cannot get Axis 1.4 working at all (never have been able to).
And I just regenerated the files with CXF, using the -all argument this time, and tried the new classes. No luck. Same results.
Any ideas? Still struggling with this.
Thank you.
Never used CXF. does the SaveResultType look like what you'd expect ? (success / id /errors properties)
Yep, looks normal.
So use that one, CXF must do different schema type -> java type name mapping than Axis.
OK, I will use SaveResultType...
however, which library is the update method for Binding in? update(new SObject[] {updateCase})
I cannot get this method working and none of the code samples show import statements. (http://www.salesforce.com/us/developer/docs/api/Content/sforce_api_calls_update.htm)
I imagine this Binding object is from the javax.xml.ws.Binding library. However, by default, that class has no update method.
Any idea?
In axis its a class called SoapBindingStub. for your toolkit you'll have to read the docs on what class name is generated for the binding/operations defined in the WSDL.
Rats, no luck. I've dug through the documentation for CXF and have done about a hundred google searches to no avail. I just can't find anything similar. I really hope I won't have to redo things in Axis now - this is a fairly mature integration that has worked flawlessly for everything else. Arg, SOAP.
You ought to be able to grep all the generated files to find it, look for the class that has all the login / create /update methods in it.