I got an error:
Object reference not set to an instance of an object
I'm missing something here in the request, but couldn't figure it out. Any help is appreciated.
I tried using soap module as well as strong-soap module, but the same error occurs in both. So it might be the error in request arguments.
Object reference not set to an instance of an object
Code:
"use strict";
var soap = require('strong-soap').soap;
var url = 'http://test.eprabhu.com/Api/Utility.svc?wsdl&UserName=CLIENT';
var requestArgs = {
'UserName': 'CLIENT',
'Password': 'CLIENT12',
'OperatorCode': 2,
'MobileNumber': '9803111111',
'Amount': 100,
'PartnerTxnId': 'P201904220218335187'
};
var options = {
'user-agent': 'sampleTest',
'Content-Type': 'text/xml;charset=UTF-8',
// 'soapAction': 'http://test.eprabhu.com/Api/Utility.svc?wsdl#MobileTopup',
'soapAction': 'http://tempuri.org/IUtility/MobileTopup'
};
soap.createClient(url, options, function(err, client) {
var method = client['MobileTopup'];
method(requestArgs, function(err, result, envelope, soapHeader) {
//response envelope
console.log('Response Envelope: \n' + envelope);
//'result' is the response body
console.log('Result: \n' + JSON.stringify(result));
console.log('Soap Header: \n', soapHeader);
});
});
Any help will be appreciated. Thanks
Change your args to:
var requestArgs = {
MobileTopupRequest: {
UserName: 'CLIENT',
Password: 'CLIENT12',
OperatorCode: 2,
MobileNumber: '9803111111',
Amount: 1,
PartnerTxnId: 'P201904220218335187'
}
};