How to add a Soap header to a Java client
1006833May 2 2013 — edited May 12 2013Hello,
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.