Pratiti Das
Pratiti Das

Reputation: 13

Error: Invalid XML format for soap client in node (Fedex)

I am using soap in node to make requests to Fedex Web Services for uploading of the documents. The document to be uploaded can be a valid file type converted to base64 (let's say, a pdf of multiple pages). If this PDF had to have a single page, the flow works completely fine. But, if the PDF is of multiple pages, I receive the following error from Fedex:

"Invalid XML","detail":"Error: Unexpected close tag\nLine: 0\nColumn: 127\nChar: >".

To debug this, I have extracted the xml request that is being sent to fedex:

<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  xmlns:ns="http://fedex.com/ws/uploaddocument/v11"><soap:Body><ns:UploadDocumentsRequest xmlns:ns="http://fedex.com/ws/uploaddocument/v11" xmlns="http://fedex.com/ws/uploaddocument/v11"><ns:WebAuthenticationDetail><ns:UserCredential><ns:Key>*******</ns:Key><ns:Password>******</ns:Password></ns:UserCredential></ns:WebAuthenticationDetail><ns:ClientDetail><ns:AccountNumber>*****</ns:AccountNumber><ns:MeterNumber>*****</ns:MeterNumber></ns:ClientDetail><ns:Version><ns:ServiceId>cdus</ns:ServiceId><ns:Major>11</ns:Major><ns:Intermediate>0</ns:Intermediate><ns:Minor>0</ns:Minor></ns:Version><ns:OriginCountryCode>IN</ns:OriginCountryCode><ns:DestinationCountryCode>CN</ns:DestinationCountryCode><ns:Usage>ELECTRONIC_TRADE_DOCUMENTS</ns:Usage><ns:Documents><ns:CustomerReference></ns:CustomerReference><ns:DocumentType>PRO_FORMA_INVOICE</ns:DocumentType><ns:FileName>1810e200-4467-11e8-b6a8-07a18eeb7b1a.pdf-test.pdf</ns:FileName><ns:DocumentContent>Base64String</ns:DocumentContent></ns:Documents></ns:UploadDocumentsRequest></soap:Body></soap:Envelope>  

The variable 'Base64String' in the request can be assumed as the file being sent. Any help on what is this error and how does this make sense? Let me know if there's any other information which might be needed

Upvotes: 0

Views: 861

Answers (1)

Anshul Verma
Anshul Verma

Reputation: 1091

If you are using xml2js to convert your request, which is most likely the case, make sure you upgrade to the version 0.4.2. Remove it first and then install that version:

npm uninstall --save xml2js  
npm install --save [email protected]

This issue has been handled in this version

Upvotes: 2

Related Questions