+ Start a Discussion
CloudResearchCloudResearch 

Web Services API problem

I am trying to call Salesforce API from my Java application in NetBeans. I imported Partner wsdl into NetBeans and create web service client using appropriate wizard. Login() and logout() operations finished successfully, but when I call describeGlobal() an error occurs (SEVERE: com.sforce.soap.partner.UnexpectedErrorFault: UNKNOWN_EXCEPTION: Destination URL not reset. The URL returned from login must be set in the SforceService). I find in Salesforce documentation that I need to set the session id in the SOAP header and specify the server URL as the target for subsequent service requests, but I do not know how to do it. Does anyone work also in NetBeans and have example/tutorial that shows solution of mentioned problem?

 

 

Yours sincerely,
Darko Androcec

Best Answer chosen by Admin (Salesforce Developers) 
_Prasu__Prasu_

You can find whole code related to this in the Email to Case application. Following is the link for the same.

http://wiki.developerforce.com/page/Members:Email_To_Case

Its a open source application, you can download its code.

 

If you want I can help you with the JAX-WS code also.

All Answers

_Prasu__Prasu_

Does following code helps?

 

 binding._setProperty(SoapBindingStub.ENDPOINT_ADDRESS_PROPERTY, loginResult.getServerUrl());

        // Create a new session header object and set the session id to that
        // returned by the login
        SessionHeader sh = new SessionHeader();
        sh.setSessionId(loginResult.getSessionId());
        binding.setHeader(new SforceServiceLocator().getServiceName().getNamespaceURI(), "SessionHeader", sh);

 

CloudResearchCloudResearch

A variable binding is instance of which class? I have found similar code at http://boards.developerforce.com/t5/Java-Development/Problem-Calling-Apex-WebService-from-Java/td-p/206637.
SoapBindingStub does not exist in com.sforce.soap.enterprise.* when I generate Java web client classes from enterprise.wsdl using Netbeans, so I can not solve my problem using this code. Or am I doing something wrong?

_Prasu__Prasu_

Its a instance of "SoapBindingStub".

 

Let me know if you still find it difficult to understand, I can point you to some more inforamtion.

CloudResearchCloudResearch

When I create JAX-WS web service client from enterprise.wsdl in my environment, "SoapBindingStub" class simply does not exist, so please point me to some more information...

 

 



_Prasu__Prasu_

You can find whole code related to this in the Email to Case application. Following is the link for the same.

http://wiki.developerforce.com/page/Members:Email_To_Case

Its a open source application, you can download its code.

 

If you want I can help you with the JAX-WS code also.

This was selected as the best answer
CloudResearchCloudResearch

This example helped me to solve my problem. I finally managed to connect and call wanted API operations, I give up JAX-WS and instead use The Force.com Web Services Connector (WSC) as in the example. If someone will deal with a similar problem, the following link is also very useful: http://wiki.developerforce.com/page/Introduction_to_the_Force.com_Web_Services_Connector.

 

Thank you,

Darko