我正在使用节点soap包来使用以下soap服务:https://paymentsuat.mppglobal.com/interface/mpp/ipaypaymentpages/ipaypaymentpages.asmx?wsdl
对于iPayPaymentPagesSoap端口,有两个名称相同但参数不同的操作。
使用描述功能节点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,但在这种情况下我只能使用它!
我被困在同一行为中,似乎到节点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);
});