ShoppingService ss = new ShoppingService();
ShoppingServiceSoap port = ss.getShoppingServiceSoap();
Client client = ClientProxy.getClient(port);
// Creating HTTP headers
Map<String, List<String>> headers = new HashMap<String, List<String>>();
headers.put("XXX-SOA-SERVICE-NAME", Arrays.asList("SampleService"));
headers.put("XXX-SOA-APP-NAME", Arrays.asList("SampleServiceAppv1"));
// Add HTTP headers to the web service request
client.getRequestContext().put(Message.PROTOCOL_HEADERS, headers);
2. soap 헤더 추가
ShoppingService ss = new ShoppingService();
ShoppingServiceSoap port = ss.getShoppingServiceSoap();
Client client = ClientProxy.getClient(port);
List<Header> headersList = new ArrayList<Header>();
Header testSoapHeader1 = new Header(ss.SERVICE, "SOAP Header Message 1", new JAXBDataBinding(String.class));
Header testSoapHeader2 = new Header(new QName("http://naver.com", "soapheader2"), "SOAP Header Message 2", new JAXBDataBinding(String.class));
Header testSoapHeader3 = new Header(new QName("Element"), "SOAP Header Message 3", new JAXBDataBinding(String.class));
headersList.add(testSoapHeader1);
headersList.add(testSoapHeader2);
headersList.add(testSoapHeader3);
// Add SOAP headers to the web service request
client.getRequestContext().put(Header.HEADER_LIST, headersList);
/* 실제 request
...
<soap:Header>
<ShoppingService xmlns="http://www.auction.co.kr/APIv1/ShoppingService">SOAP Header Message 1</ShoppingService>
<soapheader2 xmlns="http://naver.com">SOAP Header Message 2</soapheader2>
<EncryptedTicket>SOAP Header Message 3</EncryptedTicket>
...
*/
댓글 없음:
댓글 쓰기