我有一个 WCF WebService,我想使用 ColdFusion 来使用。常规过程是使用 CFHTTP 来处理 WSDL,并在正文中包含 SOAP 请求。通常情况下,这是有效的,一切都工作正常。
<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#">
运行页面后,我得到一个The security context token is expired or is not valid. The message was not processed.
回复。在阅读服务提供商的文档时,我似乎不能只将 XML 发布到 URL 并收工: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.
因此,在下载并安装 Visual Studio 代码后,我运行 svcutil.exe 并从中获取了两个文件:一个 C# 代码,它似乎设置了一大堆变量,然后执行一些操作。还有一个output.config
文件,它是一个包含端点地址的 XML 文件。
作为最后的手段,我尝试使用调用 WSDLCFINVOKE
:
<cfinvoke webservice="https://www.example.com/OtherService.svc?wsdl" method="getVersion" username="myUsername" password="myPassword" returnvariable="wsdl">
</cfinvoke>
<cfdump var="#wsdl#">
这次我得到了一个不同的错误:org.apache.axis2.AxisFault: com.ctc.wstx.exc.WstxUnexpectedCharException: Unexpected character '"' (code 34) in DOCTYPE declaration; expected a space between public and system identifiers
我的问题是:我现在该怎么办?