+ Start a Discussion
AshesAshes 

Avoiding hard coding of SOAP address in WSDL

Hi,

We are implementing Webservice for one of client. Its two integration between Salesforce and third party. For Inbound integration, we have provided login WSDL(To login and to get session id) and after getting successful session id, to send information to Salesforce we are using another WSDL file. For login WSDL we are using https://test.salesforce.com/services/Soap/c/34.0 (For Test) and https://login.salesforce.com/services/Soap/c/34.0 (For Prod). 
But in another WSDL (use to send data to Salesforce), we are not able to use test.salesforce and login.salesforce. Instead, we are using https://cs23.salesforce.com/services/Soap/class/ASRP_WaiverWebservice. We want to avoid using hard coding. Its urgent. 

Thanks
Alexander TsitsuraAlexander Tsitsura
Hi Ashes

You can create custom setting, and get url value from this settings in your soap generated class

In this screen you can view my soap class, i created hierarchy custom settings. You can create constructor, and write this logic in constructor
User-added image

As a common practice, if your question is answered, please choose 1 best answer. 
But you can give every answer a thumb up if that answer is helpful to you.

Thanks,
Alex
AshesAshes
Hi Alexander,

Thanks for your response. This is inbound Integration. It means third party is trying to send data to Salesforce by using Salesforce endpoint. Currently we are using https://cs23.salesforce.com/services/Soap/class/ASRP_WaiverWebservice as a endpoint which is hard coded and we don't want this hard coding. Because after Sandbox refresh it changes the URL. 
Alexander TsitsuraAlexander Tsitsura

If i understand correctly, u use Login method fro, soap class. This method should return LoginResult, which contacins serverUrl, and from this url you can retrieve org instancse(in u example it's "cs23") and after make link.
User-added image

https://<instanse retrieved from LoginResult.sercerUrl>.salesforce.com/services/Soap/class/ASRP_WaiverWebservice

Thanks
James LoghryJames Loghry
Yep Alexendar is correct.

You will issue a login request, using either login.salesforce.com (if production) or test.salesforce.com (if sandbox).  In the response of the login call, you will get back a server URL which will contain your sandbox domain or production domain (e.g. csXX or naXX).  You'll retrieve this and then use it as the endpoint for any subsequent calls you'll make with the wsdl.

Additionally, for testing this solution, I highly recommend Soap UI.  You can import the enterprise, partner, or other WSDL and then test the login and any other operations you'll need to call.

If this works for you, please mark Alex's answer as the best answer.

- James
AshesAshes

Hi James/alexander,

Apology for late reply. Thanks for your valuable inputs. May I know how can we retrieve this salbdonx or production domain. 

Thanks,

Ashes