Javascript 如何使用节点soap创建自定义请求
这是我需要发送到Javascript 如何使用节点soap创建自定义请求,javascript,node.js,xml,soap,wsdl,Javascript,Node.js,Xml,Soap,Wsdl,这是我需要发送到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:
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>
任何帮助都将不胜感激这可能不是最好的解决方案,但对我来说很有效。 在回调createCliete中,用我想要的xmlns重写属性
client.wsdl.xmlnsinedevelope
,client.wsdl.xmlnsinedevelope='xmlns:tem='http://tempuri.org/"';代码>
完整代码:
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)
});
});
soap.createClient(URL,wsdlOptions,函数(err,client){
client.wsdl.xmlnsinedevelope='xmlns:tem='http://tempuri.org/"';
常量args={
_xml:'DEMO010233001 Pruebas1a$',
}
ConsultarCreditos(参数,函数(错误,结果,原始,soapHeader){
console.log('last request:',client.lastRequest)
});
});
结果:
<?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>
DEMO010233001
Pruebas1a$
非常感谢您。你挽救了这一天。
> xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
> xmlns:tem="http://tempuri.org/"
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)
});
});
<?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>