user891859
user891859

Reputation: 293

Consuming Salesforce WSDL via Coldfusion Issue

Ive been given a class file from another group of SFDC developers that work in a separate instance that generates a SOAP based WSDL. I have imported that class file and generated the WSDL in our instance. The webservice is very basic, it just returns a set of values (in XML of course) and doesn't require any arguments to retrieve those values.

Just to test that the WSDL is working Ive downloaded the WSDL from our instance to my local PC and put it into SOAPUI and successfully returned the set of values.

NOW ONTO THE ISSUE - CONSUMING VIA THE URL

Im using Coldfusion's CFHTTP, so I have two CFHTTP calls, the first is to the login of our instance which returns a valid session ID. This session ID is used in my second call which is below:

<!--- 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_FAKE_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_FAKE_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>

Below is what I am receiving from the WSDL..that code just takes me back to the login screen. With a Session ID I would assume I wouldn't need to log back in, correct?

enter image description here

All advice is appreciated.

Upvotes: 0

Views: 1209

Answers (1)

superfell
superfell

Reputation: 19040

You appear to be sending your APi call to the URL of the WSDL file, this is not the correct URL, you should be sending it to the service address that's detailed within the WSDL file, see the soap:address element in the service element at the bottom of the WSDL.

Upvotes: 3

Related Questions