function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
RvanderwerfRvanderwerf 

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


SuperfellSuperfell
You should download the current WSDL and regenerate your stub classes.
RvanderwerfRvanderwerf
Thanks I did rebuild the stubs, however we use Axis2, and I followed the information found here:

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

SuperfellSuperfell
I wouldn't bother with axis2, its more trouble than its worth, stick to axis 1.x
RvanderwerfRvanderwerf
I generated the classes under axis 1.4, and it seems to work now when I call the retrieve method to get a user details that I want. Thanks for you help Simon.

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
SuperfellSuperfell
There is no official stance on "supported" vs "unsupported" tools, we're happy to relate our experiences with the various toolkits we've tried out, but at the end of the day, the supported API is the SOAP API as detailed by the WSDL/Schema documents. We don't care how you generate and parse those chunks of XML as long as the conform to the schema. It can be no other way really, there's 100+ SOAP toolkits all of which support various subsets of the various specs, we can't really police those 100+ projects to ensure they support the subset of SOAP/WSDL/XSD that's required to be sucessful with our Web Services API.

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.
RvanderwerfRvanderwerf
Some things I love about Axis2

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.
SuperfellSuperfell
Thanks, but that's primarily reasons to build servers with axis2, not clients.