2012-05-11 26 views
0


我試圖消耗Web服務從webserivce獲得運價「http://www.wwexship.com/webServices/services/FreightShipmentQuote?wsdl」,它是給人一個錯誤,「Web服務操作getShipmentSimpleQuote與無法找到參數{....}「。而我提供有效的登錄ID,密碼,許可證密鑰,帳號和其他必需的詳細信息。

請建議我如何使用此webservice?
WSDL文件 -如何在使用WWEx webservice時解決錯誤?

<?xml version="1.0" encoding="UTF-8"?> 
<wsdl:definitions targetNamespace="http://www.wwexship.com" xmlns:impl="http://www.wwexship.com" xmlns:intf="http://www.wwexship.com" xmlns:apachesoap="http://xml.apache.org/xml-soap" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"> 
<!--WSDL created by Apache Axis version: 1.4 
Built on Apr 22, 2006 (06:55:48 PDT)--> 
<wsdl:types> 
    <schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.wwexship.com" elementFormDefault="qualified"> 
    <complexType name="AuthenticationToken"> 
    <sequence> 
    <element name="loginId" nillable="true" type="xsd:string"/> 
    <element name="password" nillable="true" type="xsd:string"/> 
    <element name="licenseKey" nillable="true" type="xsd:string"/> 
    <element name="accountNumber" nillable="true" type="xsd:string"/> 
    </sequence> 
    </complexType> 
    <element name="AuthenticationToken" type="impl:AuthenticationToken" maxOccurs="1"/> 
    <complexType name="QuoteLineItem"> 
    <sequence> 
    <element name="nmfcClass" nillable="true" type="xsd:string"/> 
    <element name="weight" nillable="true" type="xsd:string"/> 
    </sequence> 
    </complexType> 
    <complexType name="ArrayOfQuoteLineItem"> 
    <sequence> 
    <element name="lineItem" nillable="true" type="impl:QuoteLineItem" maxOccurs="unbounded"/> 
    </sequence> 
    </complexType> 
    <complexType name="FreightShipmentQuoteRequest"> 
    <sequence> 
    <element name="senderCity" nillable="true" type="xsd:string"/> 
    <element name="senderState" nillable="true" type="xsd:string"/> 
    <element name="senderZip" nillable="true" type="xsd:string"/> 
    <element name="receiverCity" nillable="true" type="xsd:string"/> 
    <element name="receiverState" nillable="true" type="xsd:string"/> 
    <element name="receiverZip" nillable="true" type="xsd:string"/> 
    <element name="lineItems" nillable="true" type="impl:ArrayOfQuoteLineItem"/> 
    <element name="hazmatShipment" nillable="true" type="xsd:string"/> 
    <element name="insidePickup" nillable="true" type="xsd:string"/> 
    <element name="liftgatePickup" nillable="true" type="xsd:string"/> 
    <element name="residentialPickup" nillable="true" type="xsd:string"/> 
    <element name="tradeshowPickup" nillable="true" type="xsd:string"/> 
    <element name="constructionSitePickup" nillable="true" type="xsd:string"/> 
    <element name="insideDelivery" nillable="true" type="xsd:string"/> 
    <element name="liftgateDelivery" nillable="true" type="xsd:string"/> 
    <element name="residentialDelivery" nillable="true" type="xsd:string"/> 
    <element name="tradeshowDelivery" nillable="true" type="xsd:string"/> 
    <element name="constructionSiteDelivery" nillable="true" type="xsd:string"/> 
    <element name="notifyBeforeDelivery" nillable="true" type="xsd:string"/> 
    </sequence> 
    </complexType> 
    <element name="freightShipmentQuoteRequest" type="impl:FreightShipmentQuoteRequest"/> 
    <complexType name="ErrorDescription"> 
    <sequence> 
    <element name="errorDescription" nillable="true" type="xsd:string" maxOccurs="unbounded"/> 
    </sequence> 
    </complexType> 
    <complexType name="CarrierQuoteResult"> 
    <sequence> 
    <element name="carrierName" nillable="true" type="xsd:string"/> 
    <element name="carrierSCAC" nillable="true" type="xsd:string"/> 
    <element name="totalPrice" nillable="true" type="xsd:string"/> 
    <element name="transitDays" nillable="true" type="xsd:string"/> 
    <element name="interline" nillable="true" type="xsd:string"/> 
    <element name="guaranteedService" nillable="true" type="xsd:string"/> 
    <element name="highCostDeliveryShipment" nillable="true" type="xsd:string"/> 
    <element name="nmfcRequired" nillable="true" type="xsd:string"/> 
    </sequence> 
    </complexType> 
    <complexType name="ArrayOfCarrierQuoteResult"> 
    <sequence> 
    <element name="carrierQuoteResult" nillable="true" type="impl:CarrierQuoteResult" maxOccurs="unbounded"/> 
    </sequence> 
    </complexType> 
    <complexType name="FreightShipmentQuoteResponse"> 
    <sequence> 
    <element name="responseStatusCode" nillable="true" type="xsd:string"/> 
    <element name="responseStatusDescription" nillable="true" type="xsd:string"/> 
    <element name="errorDescriptions" nillable="true" type="impl:ErrorDescription"/> 
    <element name="quoteResults" nillable="true" type="impl:ArrayOfCarrierQuoteResult"/> 
    </sequence> 
    </complexType> 
    <element name="freightShipmentQuoteResponse" type="impl:FreightShipmentQuoteResponse"/> 
    </schema> 
</wsdl:types> 
<wsdl:message name="getShipmentSimpleQuoteResponse"> 
    <wsdl:part name="freightShipmentQuoteResponse" element="impl:freightShipmentQuoteResponse"/> 
</wsdl:message> 
<wsdl:message name="FreightShipmentQuoteRequestHeaders"> 
    <wsdl:part name="authenticationToken" element="impl:AuthenticationToken"/> 
</wsdl:message> 
<wsdl:message name="getShipmentSimpleQuoteRequest"> 
    <wsdl:part name="freightShipmentQuoteRequest" element="impl:freightShipmentQuoteRequest"/> 
</wsdl:message> 
<wsdl:portType name="FreightShipmentQuote"> 
    <wsdl:operation name="getShipmentSimpleQuote" parameterOrder="freightShipmentQuoteRequest"> 
    <wsdl:input name="getShipmentSimpleQuoteRequest" message="impl:getShipmentSimpleQuoteRequest"/> 
    <wsdl:output name="getShipmentSimpleQuoteResponse" message="impl:getShipmentSimpleQuoteResponse"/> 
    </wsdl:operation> 
</wsdl:portType> 
<wsdl:binding name="FreightShipmentQuoteSoapBinding" type="impl:FreightShipmentQuote"> 
    <wsdlsoap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/> 
    <wsdl:operation name="getShipmentSimpleQuote"> 
    <wsdlsoap:operation soapAction=""/> 
    <wsdl:input name="getShipmentSimpleQuoteRequest"> 
    <wsdlsoap:body use="literal"/> 
    <wsdlsoap:header message="impl:FreightShipmentQuoteRequestHeaders" part="authenticationToken" use="literal"> 
    </wsdlsoap:header> 
    </wsdl:input> 
    <wsdl:output name="getShipmentSimpleQuoteResponse"> 
    <wsdlsoap:body use="literal"/> 
    </wsdl:output> 
    </wsdl:operation> 
</wsdl:binding> 
<wsdl:service name="FreightShipmentQuoteService"> 
    <wsdl:port name="FreightShipmentQuote" binding="impl:FreightShipmentQuoteSoapBinding"> 
    <wsdlsoap:address location="http://www.wwexship.com/webServices/services/FreightShipmentQuote"/> 
    </wsdl:port> 
</wsdl:service> 
</wsdl:definitions> 

調用webservice的是 -

<!--- items data ---> 
<cfset items = arrayNew(1) /> 
<cfset str = structNew() /> 
<cfset str.nmfcClass = "apple" /> 
<cfset str.weight = "15" /> 
<cfset arrayAppend(items, str) /> 

<!--- freightShipmentQuoteRequest data---> 
<cfset st = structNew() /> 
<cfset st.senderCity = "Freeport" /> 
<cfset st.senderState = "NY" /> 
<cfset st.senderZip = "11520" /> 
<cfset st.receiverCity = "Staten Island" /> 
<cfset st.receiverState = "NY" /> 
<cfset st.receiverZip = "10314" /> 
<cfset st.lineItems = "#items#" /> 
<cfset st.hazmatShipment = "N" /> 
<cfset st.insidePickup = "N" /> 
<cfset st.liftgatePickup = "N" /> 
<cfset st.residentialPickup = "N" /> 
<cfset st.tradeshowPickup = "N" /> 
<cfset st.constructionSitePickup = "N" /> 
<cfset st.insideDelivery = "N" /> 
<cfset st.liftgateDelivery = "N" /> 
<cfset st.residentialDelivery = "N" /> 
<cfset st.tradeshowDelivery = "N" /> 
<cfset st.constructionSiteDelivery = "N" /> 
<cfset st.notifyBeforeDelivery = "N" /> 

<cfinvoke 
    webservice="http://www.wwexship.com/webServices/services/FreightShipmentQuote?wsdl" 
    method="getShipmentSimpleQuote" 
    username="copssship" 
    password="password" 
    returnvariable="retTemp"> 
    <cfheader name="loginId" value="copssship"> 
    <cfheader name="password" value="password"> 
    <cfheader name="licenseKey" value="hhrWQ7RMJEDKJMh4"> 
    <cfheader name="accountNumber" value="W922601302"> 
    <!---<cfheader name="AuthenticationToken" value="#stAuth#" />---> 
    <cfinvokeargument name="freightShipmentQuoteRequest" value="#st#" /> 
    </cfinvoke> 

    <cfdump var="#retTemp#"><br/> 
    <cfoutput> 
    <b>retTemp:</b>#retTemp#<br/><br/> 
    <b>retTemp.ResponseStatusCode:</b>#retTemp.ResponseStatusCode#<br/> 
    <b>retTemp.responseStatusDescription:</b>#retTemp.responseStatusDescription#<br/> 
    <b>retTemp.errorDescriptions:</b>#retTemp.errorDescriptions[1]#<br/> 
    </cfoutput> 
+0

請顯示您嘗試的代碼以及更完整的錯誤消息。 –

+0

除非我錯過了,否則webservice定義中的參數loginId/password/licenseKey無法看到。也許你的問題是身份驗證? –

+0

您可以鏈接到您關注的任何文檔。正如Cyril所指出的那樣,登錄/許可證信息不存在於WSDL中,因此他們可能使用http/basic認證或其他方法來驗證您 – barnyr

回答

0

我無法測試此解決方案,因爲我無法登錄到該服務,但它看起來像getShipmentSimpleQuote採用名爲「freightShipmentQuoteRequest」的單個結構參數,並將您嘗試傳遞的鍵作爲參數它。

<cfinvoke 
    webservice="http:.....FreightShipmentQuote?wsdl" 
    method="getShipmentSimpleQuote" 
    returnvariable="aTemp"> 
    <cfinvokeargument name="freightShipmentQuoteRequest" value="#{ 
     "senderCity" = "Freeport", 
     "senderState" = "NY", 
     .... 
    }#" /> 
</cfinvoke> 

如果不工作,你可以嘗試prefexing所有領域「freightShipmentQuoteRequest。」即。

<cfinvokeargument name="freightShipmentQuoteRequest.senderCity" value="Freeport"/> 

我在wsdl中看不到任何對登錄參數的引用。

+0

請在上面的問題細節中找到wsdl的細節。 – UltraVoilet

1

它看起來很符合我喜歡有你傳遞那些預期arcuments之間的不匹配碼。這裏有兩件事我會嘗試:

1:使用foo = CreateObject(「webservice」,「http:// server/wsdl」);然後轉儲該對象。你應該看到它的方法和參數,這可能與你上面的論點有所不同。

2:下載並安裝Fiddler。然後啓動它並將proxyServer =「localhost」proxyPort =「8888」添加到您的呼叫中。現在ColdFusion將通過Fiddler路由所有Web服務請求,並且您可以檢查傳入和傳出遠程服務器的內容。對於這種事情來說,這是一個非常強大的技術。

我認爲克里斯是正確的,你需要傳遞一個結構作爲參數。我可以用下面的代碼調用該服務:

<cfoutput> 
<cfset shipService = CreateObject("webservice","http://www.wwexship.com/webServices/services/FreightShipmentQuote?wsdl")> 
<cfdump var="#shipService#"> 
<cfset response=shipService.getShipmentSimpleQuote({})> 
<cfdump var="#response#"> 
<cfdump var="#response.getResponseStatusCode()#"> 
<cfdump var="#response.getResponseStatusDescription()#"> 

服務返回一個失敗代碼,但它確實執行。 WSDL將FreightShipmentQuoteRequest的所有成員定義爲nillabla,這就是我的代碼工作的原因,但是當您實現的正確時,您可能需要爲lineItems元素使用一個結構數組。

+0

謝謝,我一定會試試這個.. – UltraVoilet