1

我正在使用 node-soap 包来使用以下 SOAP 服务:https ://paymentssuat.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 参数一起使用,但 node-soap 默认为 CreateSessionByGET。

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

4

1 回答 1

1

我陷入了同样的行为,似乎在 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);
});
于 2016-05-20T20:24:04.010 回答