由于header和body参数,coldfusion webservice方法调用错误“无法找到操作”

时间:2014-12-08 08:03:02

标签: web-services http coldfusion

我有一个web服务,其wsdl如下:

<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:tns="http://tempuri.org/" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:wsx="http://schemas.xmlsoap.org/ws/2004/09/mex" xmlns:wsap="http://schemas.xmlsoap.org/ws/2004/08/addressing/policy" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:msc="http://schemas.microsoft.com/ws/2005/12/wsdl/contract" xmlns:i0="ns" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:wsa10="http://www.w3.org/2005/08/addressing" xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata" name="TemperatureService" targetNamespace="http://tempuri.org/">
<wsdl:import namespace="ns" location="http://localhost:57205/TemperatureService.svc?wsdl=wsdl0"/>
<wsdl:types/>
<wsdl:binding name="BasicHttpBinding_ITemperatureService" type="i0:ITemperatureService">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="SayHello">
<soap:operation soapAction="ns/ITemperatureService/SayHello" style="document"/>
<wsdl:input name="TempRequest">
<soap:header message="i0:TempRequest_Headers" part="Id" use="literal"/>
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output name="TempResponse">
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="TemperatureService">
<wsdl:port name="BasicHttpBinding_ITemperatureService" binding="tns:BasicHttpBinding_ITemperatureService">
<soap:address location="http://localhost:57205/TemperatureService.svc"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>

我正在尝试使用coldfusion代码来使用该服务,如下所示:

<cfscript>
 wsURL = "http://localhost:57205/TemperatureService.svc?wsdl";
 ws = CreateObject("webservice", wsURL); 

  writeDump(ws);

 addSOAPRequestHeader(ws, "ns", "Id", "22363");   

 response = ws.SayHello("John"); 

  writeDump(response);

</cfscript>

但是当我浏览cfm页面时,我收到以下错误:

enter image description here

1 个答案:

答案 0 :(得分:1)

我用addSOAPRequestHeader方法和structNew的组合解决了这个问题,因为我必须在标题和正文中传递值。

<cfscript>
 wsURL = "http://localhost:57205/TemperatureService.svc?wsdl";
 ws = CreateObject("webservice", wsURL); 



 addSOAPRequestHeader(ws, "ns", "Id", "22363");

 tempRequest = structNew(); 
 tempRequest.Name = "John"; 

 response = ws.SayHello(tempRequest); 

</cfscript>