Web Services Coldfusion如何认证WWEx的Web服务getShipmentSimpleQuote?

hmtdttj4  于 2023-01-17  发布在  其他
关注(0)|答案(2)|浏览(132)

如何从**“全球快递运费报价Web服务”调用“getShipmentSimpleQuote”Web服务**?我尝试调用/使用此Web服务,但收到错误消息**“验证信息无效”**。
下面是wsdl文件数据:

WWEX货运报价服务.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>
<br/>

My coldfusion code to consume/call the webservice is-<br/>
<b>consume.cfm</b>

<!--- 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" />

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

我无法验证此Web服务,我的登录凭据为-(1)loginId = copssship
(2)密码=密码
(3)许可证密钥= hhrWQ 7 RMJEDKJMh 4
(4)帐号= W 922601302
请建议如何验证此Web服务?

syqv5f0l

syqv5f0l1#

我已经用PHP实现了http://www.wwexship.com Web服务。它工作得很好。

<?php

$items = array();
$items[] = array('nmfcClass' => '50','weight' => '10');
$items[] = array('nmfcClass' => '50','weight' => '20');
$auth = Array('loginId' => "your Id", 'password' => "Your Pass",'licenseKey'=>'Your key','accountNumber'=>'Your account no,') ;
$client = new SoapClient('wsdl.xml',array( 'trace' =>1));
$header = new SoapHeader('http://www.wwexship.com','AuthenticationToken',$auth,false);
$client->__setSoapHeaders(array($header));
$result = $client->getShipmentSimpleQuote(array('senderCity' => 'Freeport','senderState'=>'NY','senderZip'=>'11520','receiverCity'=>'Staten Island','receiverState'=>'NY', 'receiverZip'=>'10314','lineItems'=>$items));
echo '<pre>';
print_r($result);
dgiusagp

dgiusagp2#

我想我可能知道答案了。身份验证信息被指定为标头。ColdFusion为此类情况提供了AddSoapRequestHeader()方法。它似乎希望值为文本或XML。下面的代码将运行并获得成功代码。请注意,除了添加标头外,我还将NMFC代码更改为300,权重更改为2。服务抱怨初始值。

shipService = CreateObject("webservice","http://www.wwexship.com/webServices/services/FreightShipmentQuote?wsdl");

doc = XmlNew();
doc.xmlRoot = XmlElemNew(doc, "http://www.wwexship.com", "AuthenticationToken");

loginId = XmlElemNew(doc, "http://www.wwexship.com", "loginId");
loginId.XmlText = "copssship";
loginId.XmlAttributes["xsi:type"] = "xsd:string";
doc.xmlRoot.XmlChildren[1] = loginId;

password = XmlElemNew(doc, "http://www.wwexship.com", "password");
password.XmlText = "password";
password.XmlAttributes["xsi:type"] = "xsd:string";
doc.xmlRoot.XmlChildren[2] = password;

licenseKey = XmlElemNew(doc, "http://www.wwexship.com", "licenseKey");
licenseKey.XmlText = "hhrWQ7RMJEDKJMh4";
licenseKey.XmlAttributes["xsi:type"] = "xsd:string";
doc.xmlRoot.XmlChildren[3] = licenseKey;

accountNumber = XmlElemNew(doc, "http://www.wwexship.com", "accountNumber");
accountNumber.XmlText = "W922601302";
accountNumber.XmlAttributes["xsi:type"] = "xsd:string";
doc.xmlRoot.XmlChildren[4] = accountNumber;

AddSOAPRequestHeader(shipService,"http://www.wwexship.com","authenticationToken",doc);

response=shipService.getShipmentSimpleQuote(st);

相关问题