与Node JS一起使用Soap API时出错

时间:2019-03-10 19:06:36

标签: node.js json soap soap-client node-soap

我已经使用PHP's SoapClient实现了SOAP API,对我来说很好用

下面是工作代码

$soapClient = new SoapClient('https://api4481.service.processPayment/Service_1_0.svc?wsdl');
$params = [
    'ClientInfo' => [
        'AccountNumber'      => 'A2342535',
        'AccountSalt'        => 'jdv89df',
        'UserName'           => 'akshay@test.com',
        'Password'           => 'Pay#123',
        'Version'            => '3.0'
    ],
    'Transaction' => [
        'Reference1'  => 'test',
        'Reference2'  => '',
        'Reference3'  => '',
        'Reference4'  => '',
        'Reference5'  => ''
    ]
];
try {
    $auth_call = $soapClient->processPayment($params);
    $result = json_decode(json_encode($auth_call), true);
} catch (SoapFault $fault) {
    die('Error : ' . $fault->faultstring);
}

但是当我使用Node Soap尝试相同操作时,出现了以下错误消息:

The formatter threw an exception while trying to deserialize the message: There was an error while trying to deserialize parameter

Node JS代码:

const soap = require('soap')
let url = 'https://api4481.service.processPayment/Service_1_0.svc?wsdl';
let args = {
    "ClientInfo": {
        "UserName": "akshay@test.com",
        "Password": "Pay#123",
        "Version": "3.0",
        "AccountNumber": "A2342535",
        "AccountSalt": "jdv89df"
    },
    "Transaction": {
        "Reference1": "test",
        "Reference2": "",
        "Reference3": "",
        "Reference4": "",
        "Reference5": ""
    }
}
soap.createClient(url, function(err, client) {
    client.disableCache = true
    client.processPayment(args, function(err, result) {
        console.log(result);
    });
});

我也尝试过使用强肥皂,但是仍然无法正常工作。

提前谢谢!

0 个答案:

没有答案