I want to use node-soap to send a request to a SOAP web service but I get this error.
D:\Projects\node-sms-webservice\node_modules\soap\lib\wsdl\index.js:541
if (typeof value === 'object' && value.hasOwnProperty(this.options.attributesKey)) {
^
TypeError: Cannot read property 'hasOwnProperty' of null
at WSDL.objectToRpcXML (D:\Projects\node-sms-webservice\node_modules\soap\lib\wsdl\index.js:541:56)
at Client._invoke (D:\Projects\node-sms-webservice\node_modules\soap\lib\client.js:329:33)
at Client.enqueue (D:\Projects\node-sms-webservice\node_modules\soap\lib\client.js:189:21)
at D:\Projects\node-sms-webservice\controllers\smscontroller.js:187:16
at D:\Projects\node-sms-webservice\node_modules\soap\lib\soap.js:84:9
at WSDL.callback (D:\Projects\node-sms-webservice\node_modules\soap\lib\soap.js:42:17)
at D:\Projects\node-sms-webservice\node_modules\soap\lib\wsdl\index.js:130:23
at WSDL._processNextInclude (D:\Projects\node-sms-webservice\node_modules\soap\lib\wsdl\index.js:1057:20)
at WSDL.processIncludes (D:\Projects\node-sms-webservice\node_modules\soap\lib\wsdl\index.js:146:14)
at D:\Projects\node-sms-webservice\node_modules\soap\lib\wsdl\index.js:87:19
at process._tickCallback (internal/process/next_tick.js:61:11)
I used a code like the further code to send a request to the server but I think I have problem with my arguments.
const soap = require('soap')
/*
SOME CODE
*/
let arguments = {
'domain': process.env.API_DOMAIN,
'messageBodies': ['Test Alert'],
'recipientNumbers': '98936xxxxxx',
'senderNumbers': process.env.API_SMS_NUMBER
}
/*
SOME CODE
*/
soap.createClient(url, function(err, client) {
// Set Basic Authentication Header
client.setSecurity(new soap.BasicAuthSecurity(username, password));
client.enqueue(arguments, function(err, result, rawResponse, soapHeader, rawRequest ) {
console.log(result)
});
});
In addition to that, I use SoapUI tool to understand more about the method which I called and here is the result.
<soapenv:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soap="http://magfa.com/soap/SOAPSmsQueue" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">
<soapenv:Header/>
<soapenv:Body>
<soap:enqueue soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<domain xsi:type="xsd:string">magfa</domain>
<messageBodies xsi:type="soap:ArrayOf_xsd_string" soapenc:arrayType="xsd:string[]"/>
<recipientNumbers xsi:type="soap:ArrayOf_xsd_string" soapenc:arrayType="xsd:string[]"/>
<senderNumbers xsi:type="soap:ArrayOf_xsd_string" soapenc:arrayType="xsd:string[]"/>
<encodings xsi:type="soap:ArrayOf_xsd_int" soapenc:arrayType="xsd:int[]"/>
<udhs xsi:type="soap:ArrayOf_xsd_string" soapenc:arrayType="xsd:string[]"/>
<messageClasses xsi:type="soap:ArrayOf_xsd_int" soapenc:arrayType="xsd:int[]"/>
<priorities xsi:type="soap:ArrayOf_xsd_int" soapenc:arrayType="xsd:int[]"/>
<checkingMessageIds xsi:type="soap:ArrayOf_xsd_long" soapenc:arrayType="xsd:long[]"/>
</soap:enqueue>
</soapenv:Body>
</soapenv:Envelope>
I surfed the net and I found Node-soap: How to create a complex message with specific attributes? qustion and change my argument as mentioned in this question but I get the same error.
Would you please let me know how to fix this error.
Thanks