• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Java client web service authentication problem

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Do not threaten THIS beaver! Not even with this tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic