I am using node soap package and trying to call a WSDL function by sending request to it. The function is working fine when I tried it through SoapUI client. I want to execute it through my node application. I have used 'soap' node package in the following manner:
soap.createClient(url, function(err, client) {
if (err) {
console.log(err);
} else {
client.ProcessOrderRequest(exampleJsonRequest, function(error, processOrderResult, body) {
console.log(error)
})
}
})
I saw an example on the package's documentation that we can send json data to the function while in SoapUI I am sending xml data and it works. The same is not working in node code.
It is giving an error as below:
Fault:
{ faultcode: 500,
faultstring: 'Invalid XML',
detail: 'Error: Non-whitespace before first tag.\nLine: 0\nColumn: 1\nChar: \u001f',
statusCode: 500 }
I tried sending XML string and it is still not working. What can be issue? Thanks in advance.
I was having the same problem looking for the problem in the request, but it was really on the response from the server. Log your response from the server and double-check it is a valid XML response. The issue comes when your client get the answer and try to deserialize the XML response to a JSON object, and since it is not valid, the 'Invalid XML' is issued.
In my case, the response "404: not found: /" was sent as plain text instead of a XML message. When I changed to
"<error>404: not found: /</error>"
the issue was solved, and then I realized the root cause of the problem was in the WSDL binding definition.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With