Cannot send non-SOAP rate request to FedEx

陌路散爱 提交于 2021-01-07 06:59:24

问题


Trying to send non-SOAP rate request to FedEx. The following XML works with SOAP Env and Body when I send their SOAP endpoint. It says in the documentation that they offer an XML-only solution, and that is formatted exactly the same as the SOAP request. Sending to https://wsbeta.fedex.com:443/xml. Please let me know if anyone has any insight.

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

回答1:


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

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.

Your request should then be:

<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


来源:https://stackoverflow.com/questions/65343524/cannot-send-non-soap-rate-request-to-fedex

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!