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
dujsudujsu 

Trouble with Locating SOAP URL Endpoint

Hello,

 

I have generated a WSDL from a class I have created. I can see the generated XML in the browser, and everything looks fine, but I am having trouble consuming the webservice with the URL I am using to view the XML. I have changed the URL to server specific as well, but still having issues, so like this:

 

https://cs12.salesforce.com/services/wsdl/class/WS_TEST_WSDL

 

But the result just redirects me to the login screen. Status says OK though.

 

Here is my XML I am sending to the URL above:

 

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ws="http://soap.sforce.com/schemas/class/WS_TEST_WSDL">
<soapenv:Header>

<ws:SessionHeader>
<ws:sessionId>my token value from the login goes here</ws:sessionId>
</ws:SessionHeader>
</soapenv:Header>
<soapenv:Body>
<ws:DescribeFields/>
</soapenv:Body>
</soapenv:Envelope>

 

Does this look correct?  Since Im passing the SessionID I would assume there is no need to login again?

 

Also, I shouldn't need to setup any kind of Remote Access as I do with a REST API, is this a correct assumption as well?

 

All input is appreciated. Thanks!

 

Best Answer chosen by Admin (Salesforce Developers) 
pkurapkura

I have changed the URL to server specific as well, but still having issues, so like this:

 - I would discourage using this. What happens when Salesforce migrates you to a different instance say cs14 or cs15 etc. You've to spend time refactoring and figuring out this part again. My advice would be to use the end point method available on wsdl.

1) How are you trying to consume this webservice ? Using Apex, Java or etc ??

2) I would manually test before I try writing any code using any webservice tools available online. You could try SOAP UI and see if this works. This is just to remove any issues in accessing the web service.

 

 

 

All Answers

pkurapkura

I have changed the URL to server specific as well, but still having issues, so like this:

 - I would discourage using this. What happens when Salesforce migrates you to a different instance say cs14 or cs15 etc. You've to spend time refactoring and figuring out this part again. My advice would be to use the end point method available on wsdl.

1) How are you trying to consume this webservice ? Using Apex, Java or etc ??

2) I would manually test before I try writing any code using any webservice tools available online. You could try SOAP UI and see if this works. This is just to remove any issues in accessing the web service.

 

 

 

This was selected as the best answer
dujsudujsu

Hey @pkura,

 

Thanks for the reply.

 

Are you saying to use this URL? http://soap.sforce.com/schemas/class/WS_TEST_WSDL

 

I can consume a downloaded version of the WSDL perfectly through SOAPUI. But cannot connect to the WSDL via the URL through SOAPUI. I have also tried this code through Coldfusion with no success (above this code I am successfully connecting to the enterprise WSDL in order to obtain the sessionID):

 

<!--- token from from first cfhttp --->
<cfset variables.access_token_node = xmlSearch(XMLContent, "//*[name()='sessionId']") />
<cfset variables.access_token = variables.access_token_node[1].xmlText>

<cfset variables.wsdl_url2 = "https://cs12.salesforce.com/services/wsdl/class/WS_TEST_WSDL">

<cfset packet = CreateObject("java", "java.lang.StringBuffer") />
<cfset packet.append('<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ws="http://soap.sforce.com/schemas/class/WS_TEST_WSDL">') />
<cfset packet.append('<soapenv:Header>') />
<cfset packet.append('<ws:SessionHeader>') />
<cfset packet.append('<ws:sessionId>#variables.access_token#</ws:sessionId>') />
<cfset packet.append('</ws:SessionHeader>') />
<cfset packet.append('</soapenv:Header>') />
<cfset packet.append('<soapenv:Body>') />
<cfset packet.append('<ws:DescribesObjectFields/>') />
<cfset packet.append('</soapenv:Body>') />
<cfset packet.append('</soapenv:Envelope>') />

<cfhttp method="post" url="#variables.wsdl_url2#" result="findResponse2">
 <cfhttpparam type="HEADER" name="Accept" value="application/soap+xml, application/xml, multipart/related, text/*">
 <cfhttpparam type="HEADER" name="ACCEPT-ENCODING" value="application/soap+xml">
 <cfhttpparam type="HEADER" name="CONNECTION" value="Keep-Alive">
 <cfhttpparam type="HEADER" name="SOAPAction" value="dummy">
 <cfhttpparam type="HEADER" name="Content-Type" value="text/xml; charset=utf-8">
 <cfhttpparam type="HEADER" name="Must-Understand" value="1">
 <cfhttpparam type="Header" name="Content-Length" value="#len(trim(packet.ToString()))#">
 <cfhttpparam type="body" value="#packet.ToString()#" encoded="yes">
</cfhttp>

 

 

 

dujsudujsu

Got it working. Just FYI for anyone in the future. I found the correct URL in the bottom of the WSDL in soap:address.