6

I have a WCF WebService I would like to consume using ColdFusion. The regular process is to use CFHTTP to the WSDL with the SOAP request in the body. Normally, this works and everything is working fine.

<cfsavecontent variable="xmlBody" >
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:tem="http://tempuri.org/">
   <soap:Header/>
   <soap:Body>
      <tem:GetVersion/>
   </soap:Body>
</soap:Envelope>
</cfsavecontent>

<cfhttp url="https://www.example.com/OtherService.svc?wsdl" method="post" timeout="1200" username="myUsername" password="myPassword" >
    <cfhttpparam type="header" name="Content-Type" value="application/soap+xml;charset=UTF-8">
    <cfhttpparam type="header" name="Content-Length" value="#len(trim(xmlbody))#">
    <cfhttpparam type="header" name="soapAction" value="http://tempuri.org/GetVersion">
    <cfhttpparam type="body" name="body" value="#trim(xmlBody)#">
</cfhttp>
<cfdump var="#cfhttp#">

After running the page, I get a The security context token is expired or is not valid. The message was not processed. response back. In reading the documentation by the service provider, it seems like I can NOT just post the XML to the URL and call it a day: While WCF uses XML to post communications to the endpoint, it is required that users use Visual Studio's "Add Service Reference" or svcutil.exe to generate reference code for the service in whichever WCF-compatible language they prefer, and use that code instead of attempting to post XML directly to the service.

So, after downloading and installing Visual Studio code, I ran svcutil.exe and got two files out of it: a C# code which seems to set a whole bunch of variables and then does STUFF. There is also an output.config file which is an XML file that has the address of the endpoint.

As a final resort, I tried calling the WSDL using CFINVOKE:

<cfinvoke webservice="https://www.example.com/OtherService.svc?wsdl" method="getVersion" username="myUsername" password="myPassword" returnvariable="wsdl">
</cfinvoke>

<cfdump var="#wsdl#">

I get a different error this time: org.apache.axis2.AxisFault: com.ctc.wstx.exc.WstxUnexpectedCharException: Unexpected character '"' (code 34) in DOCTYPE declaration; expected a space between public and system identifiers

My question is: what do I do now?

Leigh
  • 28,765
  • 10
  • 55
  • 103
Chester
  • 1,081
  • 9
  • 18
  • I'm using version CF11. – Chester Oct 17 '15 at 05:33
  • I would suggest using some sort of network sniffer [like Fiddler](http://www.telerik.com/fiddler) to monitor the network traffic when calling the webservice using the Visual Studio code. Then you can try to rebuild similar packet(s) with ColdFusion. Probably still using `cfhttp`. I have always had issues trying to use `cfinvoke` with web services. It doesn't seem to give you enough control. – Miguel-F Oct 19 '15 at 14:20
  • @Miguel-F, I'll try that. Unfortunately, I have very little experience in working with Visual Studio, an issue I'm in the middle of trying to rectify. If you have any resources I can utilize, that would be immensely helpful. – Chester Oct 19 '15 at 17:23
  • Exactly what kind of security does the web service use? – Leigh Oct 20 '15 at 21:46
  • According to the documentation, it uses WsHttpBinding with a Username and Password. I don't know if I've understood everything I've read in the past couple days completely, but I know that's what the WebService uses. I've used WCFStorm, SOACleaner and SoapUI, and they all give me similar results. – Chester Oct 20 '15 at 21:56
  • So I've reached back to the Service API and found out I was pointing to the wrong URL. Got that straightened out, and I'm able to get a response back from WCFStorm. I see the XML it sent out using fiddler, and now it's matter of replicating that XML, correct? There's some stuff in the XML that I'm not quite sure how to get and I'm not sure if it's sufficient to just copy them from the original request. There's a MessageID, a Timestamp, a DigestValue and SignatureValue in there. – Chester Oct 21 '15 at 21:48

0 Answers0