2017-11-28 21 views
2

soap-requestsの送信に関してかなり厄介な問題に直面しています。node-soapを使用して正しいsoapリクエストを送信する

SOAP-UIのようなツールを使用すると、XMLで適切なSOAPリクエストを簡単に作成できます。 ノード石鹸を使ってこのSOAPリクエストを送信しようとすると、正しいXML文字列を取得できません...

ノード・ソープ・プラグインが追加された理由はわかりませんがメソッド名(GetArrBoardWithDetail)の文字列 "SoapIn"。次のコードスニペットを参照してください:

<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>

ソープ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); 
 
    }) 
 
})

親切よろしく

答えて

0

あなたが送信されるSOAPボディを上書きするnode soapドキュメントから_xmlを使用することができます。

+0

はい、それは私が問題を解決した方法です! – SamSampleman

関連する問題