2017-02-06 25 views
0

SOAPヘッダーが必要なSOAP 1.2 WSを呼び出そうとしています。2つのSOAPヘッダータグを追加する

私はSAP Hana Cloud Integrationと呼ばれる統合設計者を使用していますが、完全なXMLメッセージを受信して​​いますが、ヘッダーはなく、受信側システムはデータを受け取るためにMessageIdを受信する必要があります。スクリプトがいっぱいですが、私はonline documentationから1を取り、I'vは私のニーズに適応:私はそれが-WSに対処し、それがランダムなUUIDを生成します有効にした後、SOAPのUIを使用して動作させるために、管理

enter image description here

Iは、受信機に送信されたメッセージヘッダは以下の通りであったことが分かったSOAP UIログで

<soap:Header xmlns:wsa="http://www.w3.org/2005/08/addressing"> 
    <wsa:MessageID>uuid:8122ffc1-62ee-436c-a284-224e49988013</wsa:MessageID> 
    <wsa:Action>http://sap.com/xi/AP/HumanCapitalManagementMasterDataReplication/Global/HumanCapitalManagementMasterDataReplicationEmployeeMasterDataReplicationIn/ReplicateCompleteEmployeeMasterDataRequest</wsa:Action> 
</soap:Header> 

Iはグルービーを使用して、同じヘッダを作成しようとした:

import com.sap.gateway.ip.core.customdev.util.Message; 
import java.util.ArrayList; 
import java.util.List; 
import javax.xml.namespace.QName; 
import javax.xml.parsers.DocumentBuilder; 
import javax.xml.parsers.DocumentBuilderFactory; 
import org.apache.cxf.binding.soap.SoapHeader; 
import org.apache.cxf.headers.Header; 
import org.w3c.dom.Document; 
import org.w3c.dom.Element; 
import com.sap.it.api.ITApiFactory; 
import com.sap.it.api.securestore.SecureStoreService; 
import com.sap.it.api.securestore.UserCredential; 


def Message processData(Message message) { 
String uuid = "uuid:" + UUID.randomUUID().toString(); 

String ActionUrl ="http://sap.com/xi/AP/HumanCapitalManagementMasterDataReplication/Global/HumanCapitalManagementMasterDataReplicationEmployeeMasterDataReplicationIn/ReplicateCompleteEmployeeMasterDataRequest"; 

DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); 
dbf.setNamespaceAware(true); 
dbf.setIgnoringElementContentWhitespace(true); 
dbf.setValidating(false); 
DocumentBuilder db = dbf.newDocumentBuilder(); 
Document doc = db.newDocument(); 

//WSA MessageID 
Element MessageId = doc.createElementNS("http://www.w3.org/2005/08/addressing", "wsa:MessageID"); 
MessageId.setTextContent(uuid); 
doc.appendChild(MessageId); 

//WSA Action 
Element Action = doc.createElementNS("http://www.w3.org/2005/08/addressing", "wsa:Action"); 
Action.setTextContent(ActionUrl); 
doc.appendChild(Action); 

SoapHeader header = new SoapHeader(new QName("http://www.w3.org/2005/08/addressing", MessageId.getLocalName()), MessageId);   
header.setMustUnderstand(true); 
List headersList = new ArrayList<SoapHeader>(); 
headersList.add(header); 

SoapHeader header2 = new SoapHeader(new QName("http://www.w3.org/2005/08/addressing", Action.getLocalName()), Action);   
headersList.add(header2); 
header2.setMustUnderstand(true); 
message.setHeader("org.apache.cxf.headers.Header.list", headersList); 

return message; 
} 

しかし、ヘッダーの下に2つのルートノードを設定することは不可能です。エラーメッセージは次のとおりです。 原因:org.w3c.dom.DOMException:HIERARCHY_REQUEST_ERR:許可されていないノードを挿入しようとしました。

どのようにこれを達成するためのアイデアですか?ありがとう! BR、 アミン。

import com.sap.gateway.ip.core.customdev.util.Message; 
import java.util.HashMap; 
def Message processData(Message message) { 

     //Headers 
     def map = message.getHeaders(); 
     def value = map.get("oldHeader"); 
     message.setHeader("oldHeader", value + "modified"); 
     message.setHeader("newHeader", "yourValue"); 

     return message; 
} 

デザイナーでWebアプリケーション(ECLIPSEない)はるかに簡単:HCIでグルーヴィーなスクリプト経由

+0

あなたのテストケースの構造は何ですか?ソープイがそれらの世話をすることができるとき、なぜそんなに面白くするのですか?データが重複している場合は、その同じリクエストの生のリクエストを確認できますか?ところで、上記のスクリプトは完全ではないようですが、その一部です。最後に、groovyを使用してリクエストを送信しているか、テストステップをリクエストしていますか? – Rao

+0

私はSAP Hana Cloud Integrationと呼ばれるインテグレーションデザイナーを使用していますが、完全なXMLメッセージを受信して​​いますが、ヘッダーはなく、受信者システムはデータを受け取るためにMessageIdを受け取る必要があります。 スクリプトがいっぱいです。私はオンラインドキュメントから必要なものを取り出しました。[link](https://proddps.hana.ondemand.com/dps/d/preview/93810d568bee49c6b3d7b5065a30b0ff/2015.10/ en-US/frameset.html?999aa87a429846a4a3f3f8d5818dd0d5.html) –

+0

あなたは前のコメント/質問を更新して更新できますか? – Rao

答えて

0

コンテンツモディファイ - >メッセージヘッダの送信要求の前に - > YourHeader |定数| java.lang.String | YourValue ...

関連する問題