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
MadhuriMadhuri 

setting EndPointURL

We have a problem in getting the right URL from the Salesforce LoginResult object from Salesforce.

We thought it is required because when it goes to Salesforce production server the end point url to access the web service methods will have to be set again in the code.

We are getting the below url from the getServerURL method. Is this the correct url?

https://cs1-api.salesforce.com/services/Soap/c/12.0/4b1300DS0000000D49Z

Using this url how will our client code connect to the Salesforce web service if the project is deployed in the production environment? (Shown in bold)

Our web service url is https://cs1-api.salesforce.com/services/Soap/class/CreditorWebService

CreditorContactServiceServiceLocator serviceLocator = new CreditorContactServiceServiceLocator(); serviceLocator.setCreditorContactServiceEndpointAddress(endpointURL);
SessionHeader sh = new SessionHeader();
sh.setSessionId(sessionID);
CreditorContactServiceBindingStub stub = CreditorContactServiceBindingStub) serviceLocator.getCreditorContactService();
stub.setHeader(serviceLocator.getServiceName().getNamespaceURI(), "SessionHeader", sh);

Thanks

Madhuri 

werewolfwerewolf
As long as you're running on the sandbox that's the correct URL.  When you move to production that getServierURL method will magically give you a production URL instead.
MadhuriMadhuri

Hi werewolf,

Thanks for your reply.

The web service I am talking about is a custom developed. It does not come under the enterprise or the partner. Therefore when I create a proxy (Stub) to access the custom developed web service the url is getting hardcoded in the stub class. e.g.(https://cs1-api.salesforce.com/services/Soap/class/CreditorWebService)

In that case do we have to regenate the proxy (Stub) for the production env? Or get the right url for the production and set it explicitly using the binding

From the url which is provided by the method getServerURL (https://cs1-api.salesforce.com/services/Soap/c/12.0/4b1300DS0000000D49Z) it is very clear that we cannot connect to the custom developed web service.

Please let us know if we are in the right track.

werewolfwerewolf
Ah, OK.  Yes, you'll probably have to regenerate the stub when you get to production.