关于发送肥皂请求,我面临一个非常烦人的问题。
如果我使用 SOAP-UI 之类的工具,我可以轻松地在 XML 中构建适当的肥皂请求。但是,如果我尝试使用 node-soap 发送这个soap-request,我将无法获得正确的xml-string ...
我不知道为什么,但是 node-soap 插件将字符串“SoapIn”附加到方法名称(GetArrBoardWithDetail)。请参阅以下代码片段:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tns="http://thalesgroup.com/RTTI/2017-02-02/ldb/" xmlns:tok="http://thalesgroup.com/RTTI/2013-11-28/Token/types" xmlns:ct2007="http://thalesgroup.com/RTTI/2007-10-10/ldb/commontypes"
xmlns:ct2015="http://thalesgroup.com/RTTI/2015-11-27/ldb/commontypes" xmlns:ldbt2017="http://thalesgroup.com/RTTI/2017-02-02/ldb/types">
<soapenv:Header>
<tok:AccessToken>
<tok:TokenValue>asdf</tok:TokenValue>
</tok:AccessToken>
</soapenv:Header>
<soapenv:Body>
<tns:**GetArrBoardWithDetailsSoapIn**>
<tns:numRows>50</tns:numRows>
<tns:crs>ACY</tns:crs>
<tns:filterCrs></tns:filterCrs>
<tns:filterType>to</tns:filterType>
<tns:timeOffset>0</tns:timeOffset>
<tns:timeWindow>120</tns:timeWindow>
</tns:**GetArrBoardWithDetailsSoapIn**>
</soapenv:Body>
</soapenv:Envelope>
外部工具 SoapUI 不会附加像“SoapIn”这样的字符串。Soap UI 附加了字符串“Request”(参见下面的代码片段)。
<?xml version="1.0" encoding="utf-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tns="http://thalesgroup.com/RTTI/2017-02-02/ldb/" xmlns:tok="http://thalesgroup.com/RTTI/2013-11-28/Token/types" xmlns:ct2007="http://thalesgroup.com/RTTI/2007-10-10/ldb/commontypes"
xmlns:ct2015="http://thalesgroup.com/RTTI/2015-11-27/ldb/commontypes" xmlns:ldbt2017="http://thalesgroup.com/RTTI/2017-02-02/ldb/types">
<soapenv:Header>
<tok:AccessToken>
<tok:TokenValue>asdf</tok:TokenValue>
</tok:AccessToken>
</soapenv:Header>
<soapenv:Body>
<tns:**GetArrBoardWithDetailsRequest**>
<tns:numRows>50</tns:numRows>
<tns:crs>ACY</tns:crs>
<tns:filterCrs></tns:filterCrs>
<tns:filterType>to</tns:filterType>
<tns:timeOffset>0</tns:timeOffset>
<tns:timeWindow>120</tns:timeWindow>
</tns:**GetArrBoardWithDetailsRequest**>
</soapenv:Body>
</soapenv:Envelope>
Soap UI 生成的请求正常工作。有谁知道如何根据 Soap-UI 请求调整这部分 XML 字符串?
源代码:
soap.WSDL.prototype.ignoredNamespaces = ['targetNamespace', 'typedNamespace'];
// several options to modify the xml code of the soap request
const wsdlOptions = {
envelopeKey: 'soapenv',
'overrideRootElement': {
'namespace': 'tns',
}
};
// // creates the soapClient
soap.createClient(wsdlUrl, wsdlOptions, function(err, client) {
// adds the needed SoapHeader to the requests
client.addSoapHeader(soapHeaderXML);
// specific soap-request
client.GetArrBoardWithDetails(soapParams, function(result, err) {
var lRequest = client.lastRequest;
var prettyLRequest = prettyData.xml(lRequest);
console.log(prettyLRequest);
console.log(result);
})
})
最亲切的问候