File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Web Services and the fly likes Java client web service authentication problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Web Services
Bookmark "Java client web service authentication problem" Watch "Java client web service authentication problem" New topic

Java client web service authentication problem

palla jayakrishna

Joined: Oct 01, 2008
Posts: 7
My client code for accessing web service:

internetID = new PersonalDemographicsRequestType();
String endpointURL = "";
UM_SIRC_PERSDEMO_BindingStub stub = null;
stub = new UM_SIRC_PERSDEMO_BindingStub();
PersDemoLocator locator = new PersDemoLocator();
stub = new UM_SIRC_PERSDEMO_BindingStub(new URL(endpointURL), locator);
PersonalDemographicsResponseType fileContent = null;

//stub.setHeader("", "Security:Username", "UMWSSIRC");
//stub.setHeader("", "Security:Password", "Hiper2012Zer0409");

/* SOAPHeaderElement header = new SOAPHeaderElement(
"", "Security");
SOAPElement node = header.addChildElement("Username");
SOAPElement node2 = header.addChildElement("Password");
stub.setHeader(header) ;*/
//HttpTransportProperties.Authenticator basicAuthentication = new HttpTransportProperties.Authenticator();
// basicAuthentication.setPassword("Hiper2012Zer0409");
//stub._setProperty(org.apache.axis2.transport.http.HTTPConstants.AUTHENTICATE, basicAuthentication);
stub._setProperty(stub.USERNAME_PROPERTY, "UMWSSIRC");
stub._setProperty(stub.PASSWORD_PROPERTY, "Hiper2012Zer0409");


After running error coming as


at org.apache.axis.transport.http.HTTPSender.readFromSocket(
at org.apache.axis.transport.http.HTTPSender.invoke(
at org.apache.axis.strategies.InvocationStrategy.visit(
at org.apache.axis.SimpleChain.doVisiting(
at org.apache.axis.SimpleChain.invoke(
at org.apache.axis.client.AxisClient.invoke(
at org.apache.axis.client.Call.invokeEngine(
at org.apache.axis.client.Call.invoke(
at org.apache.axis.client.Call.invoke(
at org.apache.axis.client.Call.invoke(
at org.apache.axis.client.Call.invoke(

But when i try to run in SOAPUI its working fine so credentials are correct please help
Nischit Shetty

Joined: Feb 21, 2007
Posts: 27
Ideally your idea is correct. You have to perform more of trial and error approach to figure out what is being passed as part of request header.

If you have generated your stubs using Axis, try to do the following instead of the approach that you are following -
Sample1InterfaceService service = new Sample1InterfaceServiceLocator();
Sample1Interface stub = service.getSample1();
(Sample1SoapBindingStub)stub)._setProperty(javax.xml.rpc.Stub.USERNAME_PROPERTY, domain + "\\" + username);
((Sample1SoapBindingStub)stub)._setProperty(javax.xml.rpc.Stub.PASSWORD_PROPERTY, password);

Although I do not find any fault in your code, just experiment a different approach and check for result.
I agree. Here's the link:
subject: Java client web service authentication problem
It's not a secret anymore!