I had implementation of client using javax.xml.ws
for a soap webservice. It work fine with basic authentication. Where I am setting authentication parameters like this
bp.getRequestContext().put(BindingProvider.USERNAME_PROPERTY,"xyz");
bp.getRequestContext().put(BindingProvider.PASSWORD_PROPERTY,"xyz");
But now we have a flow with OAUTH2.0 where I have to send just a Token with Request. I almost banged my head with whole internet but couldn't find the solution using javax.xml.ws
. There are implementations using javax.ws.rs
packages but they won't work in my case as I have to use WSDL. Please share a solution so request can be sent using Authenticaton:Bearer TOKEN_STRING
Well, you can try the same but with MessageContext
.
Map<String,List<String>>headers = new HashMap<>();
headers.put("Authorization",Collections.singletonList("Bearer "+token));
bp.getRequestContext().put(MessageContext.HTTP_REQUEST_HEADERS, headers);