Wednesday, June 19, 2019

SAXParseException error when getting the values of an object sent through a SOAP request via Suitelet


SAXParseException error when getting the values of an object sent through a SOAP request via Suitelet

When creating an XML for a SOAP request that will be sent via a Suitelet, refrain from using '<' and '>' when writing elements.

e.g.
<soapenv:Header>

Doing so will result to the following errors:

    •    soapenv:Server.userExceptionorg.xml.sax.SAXParseException: Reference is not allowed in prolog.partners-java022.svale.netledger.com
    •    [#document: null]

Note: The errors specified will only fire if the nlobjResponse object returned by nlapiRequestURL(url, postdata, headers, callback, httpMethod) is used. Otherwise, the request will simply not work.

e.g.
var reqObj = nlapiRequestURL(url, postdata, headers, callback, httpMethod);
nlapiLogExecution('ERROR', 'reqObj body  = ' , reqObj.getBody());

nlapiLogExecution('ERROR', 'reqObj toXML  = ' , nlapiStringToXML(reqObj));

This is due to the XML being parsed in such a way that NetSuite does not accept. To remedy this, use '<' and '>' instead.

Disclaimer: SaxParseException can be thrown due to different factors. This article simply states one possible factor and its solution.

No comments:

Post a Comment