Reputation: 1941
I'm developing a FedEx API client to process shipments, using C#, .NET Core 3.1. Everything works if I use a SOAP message, but I want to use plain XML posts instead. I've used this method successfully with the DHL API. I don't want to use all the WCF overhead and code generation and have found the SOAP exceptions to be difficult to deal with. The docs say plain XML should work, but I have not been able to get a simple tracking request working without the SOAP envelope, and there are no examples in the docs. Wrapping a plain XML request in a SOAP envelope seems easy, but is actually pretty complicated to do programmatically for a lot of different namespaces, etc. I would prefer to get the plain XML working. Some old posts say the xml URL is different (with /xml
at the end), but the current docs do not mention any other URL than this one: https://wsbeta.fedex.com:443/web-services and I've tried adding the /xml
to the end as well.
Here's a working SOAP request:
<?xml version="1.0" encoding="utf-8"?>
<Envelope xmlns="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<Body>
<TrackRequest xmlns="http://fedex.com/ws/track/v19">
<WebAuthenticationDetail>
<UserCredential>
<Key>MYKEY</Key>
<Password>MYPWD</Password>
</UserCredential>
</WebAuthenticationDetail>
<ClientDetail>
<AccountNumber>510087380</AccountNumber>
<MeterNumber>119194031</MeterNumber>
</ClientDetail>
<TransactionDetail>
<CustomerTransactionId>***Track Request using VC#***</CustomerTransactionId>
</TransactionDetail>
<Version>
<ServiceId>trck</ServiceId>
<Major>19</Major>
<Intermediate>0</Intermediate>
<Minor>0</Minor>
</Version>
<SelectionDetails>
<PackageIdentifier>
<Type>TRACKING_NUMBER_OR_DOORTAG</Type>
<Value>794959156726</Value>
</PackageIdentifier>
</SelectionDetails>
<ProcessingOptions>INCLUDE_DETAILED_SCANS</ProcessingOptions>
</TrackRequest>
</Body>
</Envelope>
And here's the non-working plain XML:
<?xml version="1.0" encoding="utf-8"?>
<TrackRequest xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://fedex.com/ws/track/v19">
<WebAuthenticationDetail>
<UserCredential>
<Key>MYKEY</Key>
<Password>MYPWD</Password>
</UserCredential>
</WebAuthenticationDetail>
<ClientDetail>
<AccountNumber>510087380</AccountNumber>
<MeterNumber>119194031</MeterNumber>
</ClientDetail>
<TransactionDetail>
<CustomerTransactionId>***Track Request using VC#***</CustomerTransactionId>
</TransactionDetail>
<Version>
<ServiceId>trck</ServiceId>
<Major>19</Major>
<Intermediate>0</Intermediate>
<Minor>0</Minor>
</Version>
<SelectionDetails>
<PackageIdentifier>
<Type>TRACKING_NUMBER_OR_DOORTAG</Type>
<Value>794959156726</Value>
</PackageIdentifier>
</SelectionDetails>
<ProcessingOptions>INCLUDE_DETAILED_SCANS</ProcessingOptions>
</TrackRequest>
For the plain XML, I get SOAP-encoded response, stating "Error code 500 Internal system error. Please try again later."
Does anyone know the secret formatting needed to get the plain XML requests to work?
Upvotes: 0
Views: 930
Reputation: 754
That plain xml is correct: I only changed key, password, account and meter numbers, and I got a valid response.
Just to confirm, the request is a POST to https://wsbeta.fedex.com:443/xml
(url for the testing environment), the headers are Accept: image/gif, image/jpeg, image/pjpeg, text/plain, text/html, */*"
and Content-Type: text/xml
, and the body is the plain xml you included (i.e. without the SOAP elements).
Upvotes: 1