且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

无法将非SOAP速率请求发送到FedEx

更新时间:2023-11-27 15:18:34

似乎您快到了.xml文档的根元素缺少名称空间 http://fedex.com/ws/rate/v28.

It looks like you're almost there. The root element of your xml document is missing the namespace http://fedex.com/ws/rate/v28.

在SOAP消息中,名称空间将在 Envelope 元素上定义.由于通过普通XML接口发送的数据不包含包装于SOAP的包装的Envelope和Body标签,因此必须将名称空间添加到 RateRequest 元素.

In a SOAP message the namespace would be defined on the Envelope element. Because the data sent via the plain XML interface does not contain the wrapping Envelope and Body tags that are specific to SOAP, you have to add the namespace to the RateRequest element.

您的请求应为:

<RateRequest xmlns="http://fedex.com/ws/rate/v28">
  <WebAuthenticationDetail>
    <UserCredential>
      <Key>omitted</Key>
      <Password>omitted</Password>
    </UserCredential>
  </WebAuthenticationDetail>
  <ClientDetail>
    <AccountNumber>omitted</AccountNumber>
    <MeterNumber>omitted</MeterNumber>
  </ClientDetail>
  <Version>
    <ServiceId>crs</ServiceId>
    <Major>28</Major>
    <Intermediate>0</Intermediate>
    <Minor>0</Minor>
  </Version>
  <RequestedShipment>
    <ServiceType>FEDEX_2_DAY</ServiceType>
    <Shipper>
      <Address>
        <StreetLines>4500 WEST 46TH STREET</StreetLines>
        <City>CHICAGO</City>
        <StateOrProvinceCode>IL</StateOrProvinceCode>
        <PostalCode>60632</PostalCode>
        <CountryCode>US</CountryCode>
      </Address>
    </Shipper>
    <Recipient>
      <Address>
        <City>TAMPA</City>
        <StateOrProvinceCode>FL</StateOrProvinceCode>
        <PostalCode>33616</PostalCode>
        <CountryCode>US</CountryCode>
      </Address>
    </Recipient>
    <PackageCount>1</PackageCount>
    <RequestedPackageLineItems>
      <SequenceNumber>1</SequenceNumber>
      <GroupPackageCount>1</GroupPackageCount>
      <Weight>
        <Units>LB</Units>
        <Value>10</Value>
      </Weight>
    </RequestedPackageLineItems>
  </RequestedShipment>
</RateRequest>

此外,请不要忘记在请求中设置以下标头:

Also, don't forget to set the following headers in your request:

Accept: image/gif, image/jpeg, image/pjpeg, text/plain, text/html, */*
Content-Type: text/xml