使用easy-soap在node.js中实现soap客户端

时间:2017-06-20 19:48:11

标签: javascript node.js web-services soap

这是我的代码,除了call soap方法之外,每件事都有效 返回错误,请帮助:)

 "use strict";

    var easysoap = require('easysoap');

    // define soap params
    var params = {
        host: 'www.privateqa.invoice4u.co.il',
        path: '/Services/MeshulamService.svc',
        wsdl: '/Services/MeshulamService.svc?singleWsdl',
    }
/*
 * create the client
 */"
var soapClient = easysoap.createClient(params);
/*
 * get all available functions
 */
soapClient.getAllFunctions()
    .then((functionArray) => { console.log(functionArray); })
    .catch((err) => { throw new Error(err); });
/*
 * get the method params by given methodName
 */
soapClient.getMethodParamsByName('ProccessRequest')
    .then((methodParams) => {
        console.log(JSON.stringify(methodParams.request));
        // console.log(JSON.stringify(methodParams.response));
        return methodParams;
    })
    .catch((err) => { 

        console.log(err); });
  

/ *        *叫肥皂法        * /

            soapClient.call({
                method    : 'ProccessRequest',
                attributes: {
                    xmlns: "https://privateqa.invoice4u.co.il/"
                },
                params: {
                    'UserEmail'   : 'test@test.com',
                    'UserPassword': '123456',
                    'FullName': 'idan tabachnik',
                    'Phone': '0525410849',
                    'Sum': 10.00,
                    'PaymentsNum': 1,
                    'Type': 1,
                    'ReturnUrl': 'mako.co.il'
                }
}).then((callResponse) => {
    debugger;
    console.log(callResponse.data);    // response data as json
    // console.log(callResponse.body);    // response body
    // console.log(callResponse.header);  //response header
 }).catch((err) => { throw new Error(err); });

我得到的错误" UnhandledPromiseRejectionWarning:未处理的承诺拒绝"

  

http://private.invoice4u.co.il/Services/LoginService.svc

1 个答案:

答案 0 :(得分:0)

希望您已经解决了这个问题。如果没有,请检查代码的最后一行。您正在抛出错误,但是您没有写任何东西来捕获该错误。这就是为什么它显示了未处理的承诺拒绝错误。您可以打印错误,也可以编写某种方法在其他地方捕获错误。

这是link,可以帮助您解决投掷和接球错误