JAX-RPC를 사용하여 내재적 SOAP 헤더 전송
기존 JAX-RPC(Java™ API for XML-based RPC) 웹 서비스 클라이언트를 사용으로 설정하여 내재적 SOAP 헤더의 값을 전송할 수 있습니다. 내재적 SOAP 헤더를 전송하도록 클라이언트 코드를 수정하여 발신되는 웹 서비스 요청 내 특정 정보를 전송할 수 있습니다.
시작하기 전에
- WSDL(Web Services Description Language) 파일의 바인딩에서 SOAP 헤더로 선언되지만 메시지 정의가 WSDL 파일 내 portType 요소에 의해 참조되지 않는 메시지 파트입니다.
- WSDL 파일에 포함되지 않는 요소.
핸들러 및 서비스 엔드포인트는 SAAJ(SOAP with Attachments API for Java) 데이터 모델을 사용하여 내재적 또는 명시적 SOAP 헤더를 조작할 수 있습니다.
보호 SOAP 헤더는 조작할 수 없습니다. 소유 컴포넌트에 의해 보호로 선언된 SOAP 헤더(예: 웹 서비스 보안)는 클라이언트 애플리케이션이 액세스할 수 없습니다. 보호 SOAP 헤더를 조작하려고 시도하면 예외가 발생합니다.
이 태스크 정보
클라이언트 애플리케이션이 내재적 SOAP 헤더를 전송 및 수신하기 위해 스텁 오브젝트 또는 호출 오브젝트에서 특성을 설정합니다.
프로시저
결과
내재적 SOAP 헤더를 전송하도록 구성된 JAX-RPC 웹 서비스 클라이언트가 있습니다.
예
다음 프로그래밍 예는 웹 서비스 요청 및 응답 내에서 두 개의 요청 SOAP 헤더를 전송하고 한 개의 응답 SOAP 헤더를 수신하는 방법을 보여줍니다.
1 //Create the request and response hashmaps.
2 HashMap requestHeaders=new HashMap();
3 HashMap responseHeaders=new HashMap();
45 //Add "AtmUuid1" and "AtmUuid2" to the request hashmap.
6 requestHeaders.put(new QName("com.rotbank.security", "AtmUuid1"),
7 "<AtmUuid1 xmlns=\"><uuid>ROTB-0A01254385FCA09</uuid></AtmUuid1>");
8 requestHeaders.put(new QName("com.rotbank.security", "AtmUuid2"),
9 ((IBMSOAPFactory)SOAPFactory.newInstance()).createElementFromXMLString(
10 "x:AtmUuid2 xmlns:x=\"com.rotbank.security\"><x:uuid>ROTB-0A01254385FCA09
</x:uuid><x:AtmUuid2>"));
11
12 //Add "ServerUuid" to the response hashmap.
13 //If "responseHeaders" is empty, all the SOAP headers are
14 //extracted from the response message.
15 responseHeaders.put(new QName("com.rotbank.security","ServerUuid"), null);
1617 //Set the properties on the Stub object.
18 stub.setProperty(Constants.REQUEST_SOAP_HEADERS.requestHeaders);
19 stub.setProperty(Constants.RESPONSE_SOAP_HEADERS.responseHeaders);
2021 //Call the operationon the Stub.
22 stub.foo(parm2, parm2);
2324 //Retrieve "ServerUuid" from the response hashmap.
25 SOAPElement serverUuid =
26 (SOAPElement) responseHeaders.get(new QName("com.rotbank.security","ServerUuid"));
2728 //Note: "serverUuid" now equals a SOAPElement object that represents the
29 //following code:
30//"<y:ServerUuid xmlns:y=\"com.rotbank.security\"><:uuid>ROTB-0A03519322FSA01
</y:uuid></y:ServerUuid.");
2 - 3행에서는 요청 및 응답 SOAP 헤더에 사용되는 새 HashMap이 작성됩니다.
6 - 10행에서는 AtmUuid1 및 AtmUuid2 헤더 요소가 요청 HashMap에 추가됩니다.
15행에서는 ServerUuid 헤더 요소 이름 및 널값이 응답 HashMap에 추가됩니다.
18행에서는 요청 HashMap이 스텁 오브젝트의 특성으로 설정됩니다. 그러면 스텁 오브젝트에서 호출되는 조작과 연관된 각 요청 메시지에 AtmUuid1 및 AtmUuid2 헤더가 추가됩니다.
19행에서는 응답 HashMap이 스텁 오브젝트의 특성으로 설정됩니다. 그러면 스텁 오브젝트에서 호출되는 조작과 연관된 각 응답 메시지에서 ServerUuid 헤더가 추출됩니다.
22행에서는 웹 서비스 조작이 스텁 오브젝트에서 호출됩니다.
25 - 26행에서는 ServerUuid 헤더가 응답 HashMap에서 검색됩니다. 헤더가 응답 메시지에서 추출되어 웹 서비스 엔진에 의해 HashMap에 삽입되었습니다.