Error Handling

Error handling for non-SOAP operations is different from error handling for SOAP operations. The SOAP specification provides an error handling mechanism that is not present for non-SOAP operations. For a SOAP operation, a fault is returned as a SOAP exception. For a non-SOAP request, the contents of the SOAP fault are returned as an XML document. These SOAP fault documents are returned in situations such as schema validation failures or when operation types are unrecognized. In the following example, a SOAP fault document is returned from a schema validation failure in which the “AccountNumber” element was incorrectly sent as the “AccountNumberx” element:

<soapenv:Fault xmlns:soapenv="">
<faultstring>5: Schema validation failed for request.</faultstring>
<con:fault xmlns:con="">
     <con:reason>Schema validation failed for request.</con:reason>
         <con1:ValidationFailureDetail xmlns:con1="">
             <con1:message>Expected element 'AccountNumber@' instead of 'AccountNumberx@' here in element ClientDetail@</con1:message>
                 <ship:AccountNumberx xmlns:ship="">000000000</ship:AccountNumberx>
             <con1:message>Expected element 'AccountNumber@' before the end of the content in element ClientDetail@</con1:message>
                 <ship:ClientDetail xmlns:ship="">

Each reply should be checked for the Fault element to indicate failure in processing the message. Note that the normal error processing still applies; this is an additional error check for incorrect syntax in XML documents.

Keep in mind that if you use either the SOAP or non-SOAP version of FedEx Web Services, labels are returned as Base64 encoded. To print shipping labels, you must decode labels before sending them to your printer. For more information on Base64 decoding, see Creating a Label.