如何在node-soap中选择一个wsdl操作

How to choose an wsdl operation in node-soap

我正在使用 node-soap 包来使用以下 SOAP 服务:https://paymentsuat.mppglobal.com/interface/mpp/ipaypaymentpages/ipaypaymentpages.asmx?wsdl

对于iPayPaymentPagesSoap端口,有两个同名但参数不同的操作。

使用 describe 函数 node-soap 仅显示每个端口类型的最后操作。有没有办法选择调用哪个操作?

<wsdl:portType name="iPayPaymentPagesSoap">
    <wsdl:operation name="CreateSession">
        <wsdl:documentation xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
        Retrieves a Guid from the system populated with details. Used in conjunction with ipayment pages.
        </wsdl:documentation>
        <wsdl:input name="CreateSessionBySOAP" message="tns:CreateSessionBySOAPSoapIn"/>
        <wsdl:output name="CreateSessionBySOAP" message="tns:CreateSessionBySOAPSoapOut"/>
    </wsdl:operation>
    <wsdl:operation name="CreateSession">
        <wsdl:documentation xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
        Retrieves a Guid from the system populated with user details. Used in conjunction with ipayment pages.
        </wsdl:documentation>
        <wsdl:input name="CreateSessionByGET" message="tns:CreateSessionByGETSoapIn"/>
        <wsdl:output name="CreateSessionByGET" message="tns:CreateSessionByGETSoapOut"/>
    </wsdl:operation>
</wsdl:portType>

渲染到:

{
    iPayPaymentPages: {
        iPayPaymentPagesSoap: {
            CreateSession: {
                input: {
                    affiliateId: "s:int",
                    password: "s:string"
                },
                output: {
                    CreateSessionByGETResult: {
                        Guid: "s:string",
                        ErrorNumber: "s:int",
                        ErrorMessage: "s:string",
                        targetNSAlias: "tns",
                        targetNamespace: "https://secure1.mppglobal.com/interface/ipaypaymentpages/ipaypaymentpages.asmx"
                    }
                }
            }
        }
    }
}

但是,我的目标是将 CreateSession 与 CreateSessionBySOAP 参数一起使用,但节点肥皂默认为 CreateSessionByGET。

*我无法控制 WSDL,更愿意不使用 SOAP Node.js,但在这种情况下我坚持使用它!

我陷入了同样的行为,似乎进入 node-soap/lib/client.js 使用 wsdl 作为对象或 dom 对象,但在 wsdl:portTypes 它只代表最后一个操作元素。就我而言,我有 4 个同名操作,所以我是这样解决的。

        soap.createClient(url, options, function(err, client) {

        var method = client.wsdl.definitions.services.[Service].ports.[Port].binding.methods['CreateSession'];
        var location = client.wsdl.definitions.services.[Service].ports.[Port].location;

        //change method $name, method input $name
        method.$name = 'CreateSessionBySOAP';
        method.input.$name = 'CreateSessionBySOAP';

        var def= client._defineMethod(method, location);
        //invoke the method
        def(args, options, function(err, result) {
           console.log(JSON.stringify(result));
        });
         console.log(client.lastMessage);
         console.log(client.lastResponse);
});