无法向 FedEx 发送非 SOAP 费率请求
Cannot send non-SOAP rate request to FedEx
正在尝试向 FedEx 发送非 SOAP 费率请求。当我发送它们的 SOAP 端点时,以下 XML 与 SOAP Env 和 Body 一起工作。它在文档中说他们提供了一个仅 XML 的解决方案,并且其格式与 SOAP 请求完全相同。正在发送至 https://wsbeta.fedex.com:443/xml。如果有人有任何见解,请告诉我。
<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>
看起来你快到了。 xml 文档的根元素缺少命名空间 http://fedex.com/ws/rate/v28.
在 SOAP 消息中,命名空间将在 Envelope 元素上定义。因为通过普通 XML 接口发送的数据不包含包装信封和特定于 SOAP 的 Body 标记,所以您必须将命名空间添加到 RateRequest元素。
那么您的请求应该是:
<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>
此外,不要忘记在您的请求中设置以下 headers:
Accept: image/gif, image/jpeg, image/pjpeg, text/plain, text/html, */*
Content-Type: text/xml
正在尝试向 FedEx 发送非 SOAP 费率请求。当我发送它们的 SOAP 端点时,以下 XML 与 SOAP Env 和 Body 一起工作。它在文档中说他们提供了一个仅 XML 的解决方案,并且其格式与 SOAP 请求完全相同。正在发送至 https://wsbeta.fedex.com:443/xml。如果有人有任何见解,请告诉我。
<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>
看起来你快到了。 xml 文档的根元素缺少命名空间 http://fedex.com/ws/rate/v28.
在 SOAP 消息中,命名空间将在 Envelope 元素上定义。因为通过普通 XML 接口发送的数据不包含包装信封和特定于 SOAP 的 Body 标记,所以您必须将命名空间添加到 RateRequest元素。
那么您的请求应该是:
<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>
此外,不要忘记在您的请求中设置以下 headers:
Accept: image/gif, image/jpeg, image/pjpeg, text/plain, text/html, */*
Content-Type: text/xml