aspose file tools*
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
JavaRanch » Java Forums » Java » Web Services
Bookmark "Java client web service authentication problem" Watch "Java client web service authentication problem" New topic
Author

Java client web service authentication problem

palla jayakrishna
Greenhorn

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

internetID = new PersonalDemographicsRequestType();
String endpointURL = "https://csdevib.psoft-oit.umn.edu/PSIGW/PeopleSoftServiceListeningConnector";
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);
//stub.createCall();
PersonalDemographicsResponseType fileContent = null;
internetID.setInternetID("irrth002");

//stub.setHeader("cshr.umn.edu/PersDemo.1", "Security:Username", "UMWSSIRC");
//stub.setHeader("cshr.umn.edu/PersDemo.1", "Security:Password", "Hiper2012Zer0409");

/* SOAPHeaderElement header = new SOAPHeaderElement(
"cshr.umn.edu/PersDemo.1", "Security");
SOAPElement node = header.addChildElement("Username");
node.addTextNode("UMWSSIRC");
SOAPElement node2 = header.addChildElement("Password");
node2.addTextNode("Hiper2012Zer0409");
stub.setHeader(header) ;*/
//HttpTransportProperties.Authenticator basicAuthentication = new HttpTransportProperties.Authenticator();
//basicAuthentication.setUsername("UMWSSIRC");
// 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");

//stub.setUsername("UMWSSIRC");
//stub.setPassword("Hiper2012Zer0409");
fileContent=stub.persDemo(internetID);


After running error coming as


{{http://xml.apache.org/axis/}HttpErrorCode:401

(401)Unauthorized
at org.apache.axis.transport.http.HTTPSender.readFromSocket(HTTPSender.java:744)
at org.apache.axis.transport.http.HTTPSender.invoke(HTTPSender.java:144)
at org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrategy.java:32)
at org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:118)
at org.apache.axis.SimpleChain.invoke(SimpleChain.java:83)
at org.apache.axis.client.AxisClient.invoke(AxisClient.java:165)
at org.apache.axis.client.Call.invokeEngine(Call.java:2784)
at org.apache.axis.client.Call.invoke(Call.java:2767)
at org.apache.axis.client.Call.invoke(Call.java:2443)
at org.apache.axis.client.Call.invoke(Call.java:2366)
at org.apache.axis.client.Call.invoke(Call.java:1812)
at _1.edu.PersDemo.umn.cshr.UM_SIRC_PERSDEMO_BindingStub.persDemo(UM_SIRC_PERSDEMO_BindingStub.java:190)
at _1.edu.PersDemo.umn.cshr.PersDemoclient.main(PersDemoclient.java:51)


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

Joined: Feb 21, 2007
Posts: 25
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);
stub.getGreeting(someinput);


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: http://aspose.com/file-tools
 
subject: Java client web service authentication problem