Reputation: 41
This is the message I need to send to wsdl
:
<?xml version="1.0" encoding="UTF-8" ?>
<soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:tem="http://tempuri.org/">
<soapenv:Header/>
<soapenv:Body>
<tem:ConsultarCreditos>
<tem:usuario>DEMO010233001</tem:usuario>
<tem:password>Pruebas1a$</tem:password>
</tem:ConsultarCreditos>
</soapenv:Body>
</soapenv:Envelope>
I have this code:
const wsdlOptions = {
envelopeKey: "soapenv"
};
soap.createClient(URL, wsdlOptions, function(err, client) {
const args = {
_xml: '<tem:ConsultarCreditos><tem:usuario> DEMO010233001 </tem:usuario><tem:password>Pruebas1a$</tem:password></tem:ConsultarCreditos>',
}
client.ConsultarCreditos(args, function(err, result, raw, soapHeader) {
console.log('last request: ', client.lastRequest)
});
});
Which results this:
<?xml version="1.0" encoding="utf-8"?>
<soapenv:Envelope
xmlns:soapenv="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://tempuri.org/"
xmlns:msc="http://schemas.microsoft.com/ws/2005/12/wsdl/contract">
<soapenv:Body>
<tem:ConsultarCreditos>
<tem:usuario>DEMO010233001</tem:usuario>
<tem:password>Pruebas1a$</tem:password>
</tem:ConsultarCreditos>
</soapenv:Body>
</soapenv:Envelope>
I need to change the attributes of the tag soapenv:Envelope
but I don't know how to do that.
I just need these attributes:
> xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
> xmlns:tem="http://tempuri.org/"
Any help will be appreciated
Upvotes: 1
Views: 1804
Reputation: 41
May be this is no the best solution but it works for me.
In the callback createCliete override the property client.wsdl.xmlnsInEnvelope
whit the xmlns that i want, client.wsdl.xmlnsInEnvelope = 'xmlns:tem="http://tempuri.org/"';
The complete code:
soap.createClient(URL, wsdlOptions, function(err, client) {
client.wsdl.xmlnsInEnvelope = 'xmlns:tem="http://tempuri.org/"';
const args = {
_xml: '<tem:ConsultarCreditos><tem:usuario> DEMO010233001 </tem:usuario><tem:password>Pruebas1a$</tem:password></tem:ConsultarCreditos>',
}
client.ConsultarCreditos(args, function(err, result, raw, soapHeader) {
console.log('last request: ', client.lastRequest)
});
});
Result:
<?xml version="1.0" encoding="utf-8"?>
<soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:tem="http://tempuri.org/">
<soapenv:Body>
<tem:ConsultarCreditos>
<tem:usuario>DEMO010233001</tem:usuario>
<tem:password>Pruebas1a$</tem:password>
</tem:ConsultarCreditos>
</soapenv:Body>
</soapenv:Envelope>
Upvotes: 3