2014-12-08 22 views
0

我有一個web服務,其WSDL是如下:ColdFusion的web服務的方法調用錯誤「操作不能被發現」,由於頭部和主體參數

<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

+0

嘗試增加refreshwsdl'WS =的CreateObject( 「web服務」,wsURL,{refreshwsdl = 「是」});' – 2014-12-08 09:09:47

+0

@Algesan檢查傳遞給sayHello方法的參數。看起來這個方法需要2個參數String和ID。 – 2014-12-08 14:57:10

+0

這是基本上[這裏問同一個問題](http://stackoverflow.com/questions/27340622/coldfusion-webservice-exception-operation-cannot-be-found)? – Leigh 2014-12-08 15:30:31

回答

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> 
相關問題