Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How to add a Soap header to a Java client

1006833May 2 2013 — edited May 12 2013
Hello,

I am new in Web Services.I am struggling to set Header using Although is has been added through handler. But My requirement is to add Header at client side not from server side. Following test code is being used to set at header despite it is not working .

Map<String, Object> req_ctx = ((BindingProvider)c).getRequestContext();
req_ctx.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, "http://localhost:7001/CalculatorWS/CalculatorProgram?wsdl");

Map<String, List<String>> headers = new HashMap<String, List<String>>();
headers.put("Username", Collections.singletonList("mkyong"));
headers.put("Password", Collections.singletonList("password"));
req_ctx.put(MessageContext.HTTP_REQUEST_HEADERS, headers);

Please help me to solve this problem.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jun 9 2013
Added on May 2 2013
3 comments
10,971 views