【问题标题】:How to solve error while consuming WWEx webservice?使用 WWEx 网络服务时如何解决错误?
【发布时间】:2012-05-11 07:38:55
【问题描述】:


我正在尝试使用 web 服务从 webserivce "http://www.wwexship.com/webServices/services/FreightShipmentQuote?wsdl" 获取运费,它给出了一个错误,即“Web 服务操作 getShipmentSimpleQuote无法找到带有参数 {....} 的“。而我提供有效的登录 ID、密码、许可证密钥、帐号和其他必需的详细信息。

请建议我如何使用此网络服务?
wsdl 文件-

<?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>

【问题讨论】:

  • 请显示您尝试过的代码以及更完整的错误消息。
  • 除非我错过了,否则我无法在 webservice 定义中看到参数 loginId/password/licenseKey。也许您的问题是身份验证?
  • 您能否链接到您正在关注的任何文档。正如 Cyril 指出的那样,登录/许可证信息不存在于 WSDL 中,因此他们可能使用 http/basic 身份验证或其他方式对您进行身份验证
  • @barnyr:我已经用 wsdl 详细信息更新了我的问题。

标签: web-services coldfusion shipping


【解决方案1】:

在我看来,您传递的弧线与预期的弧线之间存在不匹配。这是我要尝试的两件事:

1:使用 foo=CreateObject("webservice","http://server/wsdl");然后转储对象。您应该会看到其上的方法和参数,这可能与您上面的参数不同。

2:下载并安装Fiddler。然后启动它并将 proxyServer="localhost" proxyPort="8888" 添加到您的呼叫中。 ColdFusion 现在将通过 Fiddler 路由所有 Web 服务请求,您可以检查传入和传出远程服务器的内容。对于这种事情,这是一种非常强大的技术。

我认为 Chris 是对的,您需要将结构体作为参数传递。我可以使用以下代码调用服务:

<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 元素使用结构数组。

【讨论】:

    【解决方案2】:

    我无法测试此解决方案,因为我无法登录服务,但看起来 getShipmentSimpleQuote 采用了一个名为“freightShipmentQuoteRequest”的结构参数,其中包含您尝试作为参数传递的键.

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

    如果这不起作用,您可以尝试在所有字段中添加前缀“freightShipmentQuoteRequest”。 IE。

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

    我在 wsdl 中看不到任何对登录参数的引用。

    【讨论】:

    • 请在上述问题详细信息中找到 wsdl 详细信息。
    猜你喜欢
    • 2022-10-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-05-14
    相关资源
    最近更新 更多