我正在使用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参数一起使用,但node-soap默认为CreateSessionByGET。
*我无法控制WSDL,而且宁愿不使用带有Node.js的SOAP,但在这种情况下我坚持使用它!
答案 0 :(得分: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);
});