WCF and ColdFusion

2019-06-19 03:05发布

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?

0条回答
登录 后发表回答