2017-02-06 1 views
0

SOAP 헤더가 필요한 SOAP 1.2 WS를 호출하려고합니다.두 개의 SOAP 헤더 태그 추가

SAP Hana Cloud Integration이라는 통합 디자이너를 사용하고 있는데 전체 XML 메시지를 수신하지만 헤더가없고 수신 시스템이 데이터를 받아들이려면 MessageId를 수신해야합니다. 스크립트가 가득, 나는 online documentation에서 하나를 가져다가 I'v 내 필요에 적응 : 나는-A WS를 해결하고 임의의 UUID를 생성 할 수 있도록 사용 후 SOAP UI를 사용하여 작동하도록 관리

enter image description here

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

내가 사용하여 동일한 헤더를 만들 수 그루비 시도 : 내가 발견은 SOAP UI 로그에서

는 수신기에 전송 된 메시지 헤더는 다음과 같은 것을

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

그러나 헤더 아래에 두 개의 루트 노드를 설정할 수 없다는 오류 메시지가 표시됩니다. 원인 : 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; 
} 

디자이너에서 웹 응용 프로그램 (ECLIPSE되지 않음) 훨씬 더 간단 : HCI에서 그루비 스크립트를 통해

+0

테스트 케이스 구조 란 무엇입니까? soapui가 그들을 돌볼 수있을 때, 왜 멋져요? 중복 된 데이터가있는 경우 동일한 요청에 대한 원시 요청을 확인할 수 있습니까? 그건 그렇고, 위의 스크립트는 전체가 아닌 것 같아요, 단지 그것의 일부? 마지막으로 groovy를 사용하여 요청을 보내거나 테스트 단계를 요청 하시겠습니까? – Rao

+0

SAP 통합 클라우드 통합 (SAP Hana Cloud Integration)이라는 통합 디자이너를 사용하고 있는데 전체 XML 메시지를 수신하지만 헤더가없고 수신 시스템이 데이터를 받아들이려면 MessageId를 수신해야합니다. 스크립트가 꽉 찼습니다. 온라인 문서에서 가져온 것이고, 필요에 맞게 수정했습니다 : [link] (https://proddps.hana.ondemand.com/dps/d/preview/93810d568bee49c6b3d7b5065a30b0ff/2015.10/ ko-ko/frameset.html? 999aa87a429846a4a3f3f8d5818dd0d5.html) –

+0

이전 의견/질문을 통해 업데이트 할 수 있습니까? – Rao

답변

0

내용 수정 -> 메시지 헤더 전송 요청하기 전에 -> YourHeader | 상수 | java.lang.String | YourValue ...