NodeJS proper Request SOAP

Multi tool use


NodeJS proper Request SOAP
Hello I need to do a request in SOAP, I'm Facing a problem:
{ Error: soapenv:Server: javax.xml.bind.UnmarshalException
- with linked exception:
[javax.xml.bind.UnmarshalException: unexpected element (uri:"", local:"buscaEventos"). Expected elements are <{http://resource.webservice.correios.com.br/}buscaEventos>,<{http://resource.webservice.correios.com.br/}buscaEventosLista>,<{h
ttp://resource.webservice.correios.com.br/}buscaEventosListaResponse>,<{http://resource.webservice.correios.com.br/}buscaEventosResponse>,<{http://resource.webservice.correios.com.br/}cloudMessage>,<{http://resource.webservice.correios.c
om.br/}destino>,<{http://resource.webservice.correios.com.br/}endereco>,<{http://resource.webservice.correios.com.br/}evento>,<{http://resource.webservice.correios.com.br/}objeto>,<{http://resource.webservice.correios.com.br/}rastro>,<{h
ttp://resource.webservice.correios.com.br/}rastroObjeto>]
I'm facing a problem becase the request need to be exact like this example:
(SOAP UI REFERENCE:)
<soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:res="http://resource.webservice.correios.com.br/"
>
<soapenv:Header/>
<soapenv:Body>
<res:buscaEventosLista>
<!--Optional:-->
<usuario>?</usuario>
<!--Optional:-->
<senha>?</senha>
<!--Optional:-->
<tipo>?</tipo>
<!--Optional:-->
<resultado>?</resultado>
<!--Optional:-->
<lingua>?</lingua>
<!--Zero or more repetitions:-->
<objetos>?</objetos>
</res:buscaEventosLista>
</soapenv:Body>
I was able to debug the request behind-scenes in node.js.
console.log in variable data, inside node modules,
function HttpClient.prototype.request
IN:
node_modules/soap/lib/http.js
it's sending request in this format XML:
<soap:Envelope
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"
xmlns:tns="http://resource.webservice.correios.com.br/"
>
<soap:Body>
<tns:buscaEventos>
<tns:usuario>USERHERE</tns:usuario>
<tns:senha>PASSHERE</tns:senha>
<tns:tipo>L</tns:tipo>
<tns:resultado>T</tns:resultado>
<tns:lingua>3213123</tns:lingua>
<tns:objetos>XXXXX</tns:objetos>
</buscaEventos>
</soap:Body>
And I'm able to compare requests made between two.
Judging the differente between the two requests
I need:
1 - xmlns:res="http://resource.webservice.correios.com.br/"
in Envelope
2 - Prefix res
in buscaEventos
3 - fields doesn't need res or any prefix only fields, like <usuario>
xmlns:res="http://resource.webservice.correios.com.br/"
res
<usuario>
Edit...
Probably the main problem is i need a prefix in buscaEventos and fields doesnt need anything.
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.