You need to sign in to do that
Don't have an account?
Rvanderwerf
bindig.retrieve fails...
Hello, I am trying to use the 'retrieve' core call however I get a strange exception:
org.xml.sax.SAXException: Invalid element in com.sforce.soap.enterprise.sobject.User - Id
from the following code. I've tried using the API 8.0, 9.0, 10.0, and 12.0 URLs for the call. The API 8.0 and 9.0 only work though for my binding.getUserInfo() call. All I am trying to do is get more user details about a user who is coming in through SSO. Also I am using the quickstart.jar file supplied on the SSO example page. Maybe it is too old?
SforceServiceLocator serviceLocator = new SforceServiceLocator();
SoapBindingStub binding = new SoapBindingStub();
SessionHeader sh = new SessionHeader();
sh.setSessionId(sfSessionId);
String ns = serviceLocator.getServiceName().getNamespaceURI();
binding.setHeader(ns, "SessionHeader", sh);
binding._setProperty(SoapBindingStub.ENDPOINT_ADDRESS_PROPERTY, serverURL);
// TEST a SOAP call
GetUserInfoResult userInfoResult = binding.getUserInfo(); // THIS WORKS 8.0 or 9.0 URL
serviceLocator = new SforceServiceLocator();
binding = new SoapBindingStub();
sh = new SessionHeader();
sh.setSessionId(sfSessionId);
ns = serviceLocator.getServiceName().getNamespaceURI();
binding.setHeader(ns, "SessionHeader", sh);
binding._setProperty(SoapBindingStub.ENDPOINT_ADDRESS_PROPERTY, serverURL1);
SObject[] sObjects = binding.retrieve("FirstName, LastName, Username, MobilePhone, Phone, Fax, Email, Country, CompanyName",
"User", new String[] {userInfoResult.getUserId()}); // FAILS no matter what API url I use
org.xml.sax.SAXException: Invalid element in com.sforce.soap.enterprise.sobject.User - Id
from the following code. I've tried using the API 8.0, 9.0, 10.0, and 12.0 URLs for the call. The API 8.0 and 9.0 only work though for my binding.getUserInfo() call. All I am trying to do is get more user details about a user who is coming in through SSO. Also I am using the quickstart.jar file supplied on the SSO example page. Maybe it is too old?
SforceServiceLocator serviceLocator = new SforceServiceLocator();
SoapBindingStub binding = new SoapBindingStub();
SessionHeader sh = new SessionHeader();
sh.setSessionId(sfSessionId);
String ns = serviceLocator.getServiceName().getNamespaceURI();
binding.setHeader(ns, "SessionHeader", sh);
binding._setProperty(SoapBindingStub.ENDPOINT_ADDRESS_PROPERTY, serverURL);
// TEST a SOAP call
GetUserInfoResult userInfoResult = binding.getUserInfo(); // THIS WORKS 8.0 or 9.0 URL
serviceLocator = new SforceServiceLocator();
binding = new SoapBindingStub();
sh = new SessionHeader();
sh.setSessionId(sfSessionId);
ns = serviceLocator.getServiceName().getNamespaceURI();
binding.setHeader(ns, "SessionHeader", sh);
binding._setProperty(SoapBindingStub.ENDPOINT_ADDRESS_PROPERTY, serverURL1);
SObject[] sObjects = binding.retrieve("FirstName, LastName, Username, MobilePhone, Phone, Fax, Email, Country, CompanyName",
"User", new String[] {userInfoResult.getUserId()}); // FAILS no matter what API url I use
http://wso2.org/blog/dims/2548
and I can get the getUserInfo call to work. However with retrieve I get the error:
org.apache.axis2.AxisFault: org.apache.axis2.databinding.ADBException: Unsupported type urn:sobject.enterprise.soap.sforce.com User
I've also tried with stub.query, but the only think I can get back is ID, it says unknown subelement for everything else I enter.
my code (called from a custom tab, passing in the 12.0 API url):
SforceServiceStub stub = new SforceServiceStub(serverURL);
Options options = stub._getServiceClient().getOptions();
options.setProperty(HTTPConstants.MC_ACCEPT_GZIP, Boolean.TRUE);
options.setProperty(HTTPConstants.MC_GZIP_REQUEST, Boolean.TRUE);
SessionHeader sh = new SessionHeader();
sh.setSessionId(sfSessionId);
GetUserInfo getUserInfo = new GetUserInfo();
GetUserInfoResult userInfoResult = stub.getUserInfo(getUserInfo,sh); // WORKS!
SObject[] sObjects = stub.retrieve("FirstName, LastName, Username, MobilePhone, Phone, Fax, Email, Country, CompanyName",
"User", new ID[] {userInfoResult.getUserId()},sh,null,null); // FAILS with exception
I saw your blog post at http://www.pocketsoap.com/weblog/2006/05/1623.html which had given me some hope with axis2, however it sounds like the Salesforce stuff doesn't officially work with it.
It would sure be nice and beneficial to the open source community if SF would put some effort into finding out why Axis2 doesn't work right with salesforce APIs, as Axis 1.x hasn't been updated in almost 2 years and isn't the nicest thing to use compared to Axis2.
Thanks again,
Ryan
If you want to use Axis2, go right ahead, I think its more trouble than its worth (vs Axis 1.x), YMMV. I have done some testing with Axis2 and logged various bugs, and at one point it was working although required a lot of tedious boiler plate code. I haven't tried it recently, so its entirely possible that they're re-broken something that was fixed earlier. But if you're having problems, i suggest you log bugs with the axis2 project.
You may also want to checkout this blog post from Dims who works on Axis2.
http://wso2.org/blog/dims/2548
I'm interested to hear about what you think is nicer about axis2 vs axis.
1) easy to setup out of the box, has shell scripts/batch files for commonly used things like Java2WSDL WSDL2java, etc. Scripts auto generate a build.xml for your stubs and makes a jar file for you with no fuss
2) administrator console - can hot deploy and remove services and see their status
3) hot modules - we made a module that logs data across all of our services without code changes
4) POJO support - often we have 1 off quick services to host and building a simple pojo class will automagically be greated into a soap service and marshall/unmarshall everything, without stubs, skeletons, etc.