java - Send BASIC auth credentials using cxf client -
i sending auth credentials using cxf webservice client , says:
javax.xml.ws.webserviceexception: not send message.
caused by: org.apache.cxf.transport.http.httpexception: http response '401: unauthorized' when communicating http://localhost:8080/accountfacadeservice/accountservice
my client is:
qname service_name = new qname("http://webservice.account.com/", "accountfacadeservice"); url wsdl_location = http://localhost:8080/accountfacadeservice/accountservice?wsdl; accountfacadeservice stub = new accountfacadeservice(wsdl_location, service_name); accountservice port = stub.getaccountserviceport(); ((bindingprovider) port).getrequestcontext().put(bindingprovider.username_property, "user"); ((bindingprovider) port).getrequestcontext().put(bindingprovider.password_property, "pass");
is there more headers i'm missing?
alright, after many hours of digging issue found answer question.
- make sure
role
in security realm of glassfish server console correctly configured , same maintained inglassfish-ejb-jar.xml
- the authentication credentials passed way i'm passing in post. when client unable create header may try password authenticator.
final string username = "user"; final string password = "pass"; authenticator.setdefault(new authenticator() { @override protected passwordauthentication getpasswordauthentication() { return new passwordauthentication( username, password.tochararray()); } });
Comments
Post a Comment