JAX-WS를 사용하여 내재적 SOAP 헤더 전송
기존 JAX-WS(Java™ API for XML-Based Web Service) 웹 서비스 클라이언트를 사용으로 설정하여 내재적 SOAP 헤더의 값을 전송할 수 있습니다. 내재적 SOAP 헤더를 전송하도록 클라이언트 코드를 수정하여 발신되는 웹 서비스 요청 내 특정 정보를 전송할 수 있습니다.
시작하기 전에
이 태스크를 완료하려면 내재적 SOAP 헤더를 전송하기 위해 사용으로 설정할 수 있는 웹 서비스 클라이언트가 필요합니다.
- WSDL(Web Services Description Language) 파일의 바인딩에서 SOAP 헤더로 선언되지만 메시지 정의가 WSDL 파일 내 portType 요소에 의해 참조되지 않는 메시지 파트입니다.
- WSDL 파일에 포함되지 않는 요소.
핸들러 및 서비스 엔드포인트는 SAAJ(SOAP with Attachments API for Java) 데이터 모델을 사용하여 내재적 또는 명시적 SOAP 헤더를 조작할 수 있습니다.
JAX-WS를 사용하는 경우 조작할 수 있는 헤더 유형에는 제한이 없습니다.
이 태스크 정보
클라이언트 애플리케이션이 내재적 SOAP 헤더를 전송 및 수신하기 위해 디스패치 오브젝트 또는 프록시 오브젝트에서 특성을 설정합니다.
프로시저
결과
내재적 SOAP 헤더를 전송하도록 구성된 JAX-WS 웹 서비스 클라이언트가 있습니다.
예
1 //Create the hashmaps for the outbound soap headers
2 Map<QName, List<String>> outboundHeaders=new HashMap<QName, List<String>>();
3 4 //Add "AtmUuid1" and "AtmUuid2" to the outbound map
5 List<String> list1 = new ArrayList<String>();
6 list1.add("<AtmUuid1 xmlns=\"com.rotbank.security\"><uuid>ROTB-0A01254385FCA09</uuid></AtmUuid1>");
7 List<String> list2 = new ArrayList<String>();
8 list2.add("<AtmUuid2 xmlns=\"com.rotbank.security\"><uuid>ROTB-0A01254385FCA09</uuid></AtmUuid2>"
9 outboundHeaders.put(new QName("com.rotbank.security", "AtmUuid1"), list1);
10 outboundHeaders.put(new QName("com.rotbank.security", "AtmUuid2"), list2);
11 // Set the outbound map on the request context
12 dispatch.getRequestContext().put("jaxws.binding.soap.headers.outbound");
13 // Invoke the remote operation
14 dispatch.invoke(parm1);
15 // Get the inbound header map from the response context
16 Map<QName,List<String>> inboundMap = dispatch.getResponseContext().get("jaxws.binding.soap.headers.outbound");
17 List<String> serverUuidList = inboundMap.get(new QName("com.rotbank.security","ServerUuid"));
18 String text = serverUiidList.get(0);
19 //Note: text now equals a XML object that contains a SOAP header:
21//"<y:ServerUuid xmlns:y=\"com.rotbank.security\"><:uuid>ROTB-0A03519322FSA01
22 </y:uuid></y:ServerUuid.");
2행에서는 아웃바운드 SOAP 헤더 맵을 작성합니다.
5 - 10행에서는 AtmUuid1과 AtmUuid2 헤더 요소가 아웃바운드 맵에 추가됩니다.
12행에서는 아웃바운드 맵이 요청 컨텍스트에 설정되어 조작이 호출될 때 AtmUuid1과 AtmUuid2 헤더가 요청 메시지에 추가되는 원인이 됩니다.
14행에서는 원격 조작을 호출합니다.
15행에서는 아웃바운드 헤더 맵을 얻습니다.
17 - 18행에서는 ServerUuid 헤더가 응답 맵에서 검색됩니다. 맵은 응답 메시지에서 SOAP 헤더에 액세스합니다.