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.

  1. make sure role in security realm of glassfish server console correctly configured , same maintained in glassfish-ejb-jar.xml
  2. 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

Popular posts from this blog

authentication - Mongodb revoke acccess to connect test database -

ios - Realm over CoreData should I use NSFetchedResultController or a Dictionary? -

r - Update two sets of radiobuttons reactively - shiny -