• 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:

JAX-WS Authentication problem -javax.xml.ws.WebServiceException Response: '401: Unauthorized'

 
Ranch Hand
Posts: 225
IBM DB2 Eclipse IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dear Friends ,

i am doing Webservice using JAX-WS technology .
client - jaxws one (exposed to client with WSDL ) and - calls 2nd service implemented in JAX-WS which has authentication

communication between client - jaxws one (exposed to client with WSDL ) is OK .

communication between jaxws one (exposed to client with WSDL ) and - calls 2nd service - exception occured due to authentication

javax.xml.ws.WebServiceException Response: '401: Unauthorized' for url: 'http://host/HelloService'
at com.sun.xml.ws.wsdl.WSDLContext.<init>(WSDLContext.java:68)
at com.sun.xml.ws.client.WSServiceDelegate.parseWSDL(WSServiceDelegate.java:207)
at com.sun.xml.ws.client.WSServiceDelegate.<init>(WSServiceDelegate.java:165)
at com.sun.xml.ws.spi.ProviderImpl.createServiceDelegate(ProviderImpl.java:49)
at weblogic.wsee.jaxws.spi.WLSProvider.createServiceDelegate(WLSProvider.java:18)

Caused by: java.io.FileNotFoundException: Response: '401: Unauthorized' for url: 'http://host/HelloService'


i had written autheticator class also

one more thing this works good as Junit (stand alone ) and in Tomcat

when i am deploying in weblogic i am getiing above exception .



calling class snippet
---------------------



Please suggest what needs to be done ? ( it is working as Junit and in tomcat ... in weblogic it is giving problem )

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Ganesh,
Did you find a solution to this problem? Even I am facing the same problem and have wasted 3 days without success. If you have solved it, can you please write your solution here....

--
Cherio
ASR
 
Ganesh Gowtham
Ranch Hand
Posts: 225
IBM DB2 Eclipse IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
HI Amit ,

Are you getting this authentication issue in tomcat (or) weblogic ?.

Tomcat means i do have solution ,infact for weblogic i didnt try even now as it is not in priyority list .
 
Amit A Rathore
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Let me explain what I have done.

I have 2 make 2 webservice calls. 1 set of webservices are running under axis2 1.1 which are not secured and 2nd set of webservices are running under weblogic which are secured using basic HTTP authentication. Both these services are deployed in Weblogic 9.1.

My client program makes a call to webservices running in axis2 which inturn invokes webservices running in weblogic webservices and pass authentication details to this services using Authenticator class.

This was working fine when my axis2 was deployed under tomcat, the issue occured when I moved Axis2 to weblogic container.

Does that help you to understand the problem.


STACK TRACE:
weblogic.webservice.wsdl.WSDLParseException: Failed to retrieve WSDL from http://myserver:9001/myws/snwebservice?WSDL. Please check the URL and make sure that it is a valid XML file [java.io.FileNotFoundException: Response: '401: Unauthorized' for url: 'http://myserver:9001/myws/snwebservice?WSDL']
at weblogic.webservice.wsdl.DefinitionFactory.createDefinition(DefinitionFactory.java:160)
at weblogic.webservice.wsdl.WSDLParser.<init>(WSDLParser.java:50)
at weblogic.webservice.WebServiceFactory.createFromWSDL(WebServiceFactory.java:109)
at weblogic.webservice.core.rpc.ServiceImpl.<init>(ServiceImpl.java:94)
 
Ganesh Gowtham
Ranch Hand
Posts: 225
IBM DB2 Eclipse IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Amit

infact i faced the same problem ... since tomcat --> weblogic migration is not priority it stopped working on this .

can uyou try this
 
Amit A Rathore
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ganesh,
Here is my code snippet:

// BasicHTTPAuthenticator is a subclass of java.net.Authenticator
Authenticator.setDefault(new BasicHTTPAuthenticator("myuser", "mypassword"));

// instantiate the endpoint impl. This Impl file is autogenerated as result of Weblogic ServiceGen
SupernovaWebServiceEndpoint_Impl ws = new SupernovaWebServiceEndpoint_Impl("http://myserver:9001/myws/snwebservice?WSDL");

// get the endPointPort
SupernovaWebServiceEndpointPort port = (SupernovaWebServiceEndpointPort) ws.getSupernovaWebServiceEndpointPort();

So in this code where will I add your suggested code. I thought setting Authenticator before invocation should've handled it and it does it successfully when it runs under tomcat.

--
Cheers
ASR
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hey guys any luck.. i am also running into the same issue inside weblogic
 
Ganesh Gowtham
Ranch Hand
Posts: 225
IBM DB2 Eclipse IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Amit,

Did you solution for this issue , if so could you please let us know the procedure you had followed .

Amit Rathore wrote:Ganesh,
Here is my code snippet:

// BasicHTTPAuthenticator is a subclass of java.net.Authenticator
Authenticator.setDefault(new BasicHTTPAuthenticator("myuser", "mypassword"));

// instantiate the endpoint impl. This Impl file is autogenerated as result of Weblogic ServiceGen
SupernovaWebServiceEndpoint_Impl ws = new SupernovaWebServiceEndpoint_Impl("http://myserver:9001/myws/snwebservice?WSDL");

// get the endPointPort
SupernovaWebServiceEndpointPort port = (SupernovaWebServiceEndpointPort) ws.getSupernovaWebServiceEndpointPort();

So in this code where will I add your suggested code. I thought setting Authenticator before invocation should've handled it and it does it successfully when it runs under tomcat.

--
Cheers
ASR

 
Amit A Rathore
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Ganesh,
No luck yet. I had kept this at the back burner. I have raised this issue in other forums as well but no luck yet.

If you get something, do let me know.

--
Cheers
Amit
 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
For those who may stumble on this trying to find the answer this is what I did to get it to work.



Note that I think is is not a particularly elegant solution. I think that it would be much better to be using an Authenticator or a SOAPHandler however in Weblogic 10.3.2 (and from others who have posted similar questions on the web also in previous versions of weblogic) neither of these methods appears to work.

Its also worth noting that in order to get this to work either the url to get the wsdl needs to be unsecured or you need a local copy of the wsdl and to change the static initialiser of the gererated service class

HTH

Matt
 
Ganesh Gowtham
Ranch Hand
Posts: 225
IBM DB2 Eclipse IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
HI Mathew , the same snippet works pretty well for me .
finally i copied the wsdl to host(which is secured) to weblogic server . which works for me ...

i think the solution you gave me works in axis version ..

Thanks for reply
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The proper way to secure a JAX-WS web service is really to use WS-Security, not HTTP authentication. All major JAX-WS implementations support that.
 
Ganesh Gowtham
Ranch Hand
Posts: 225
IBM DB2 Eclipse IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Ulf Dittmer wrote:The proper way to secure a JAX-WS web service is really to use WS-Security, not HTTP authentication. All major JAX-WS implementations support that.



This is case , where i expose soem service which in-turn i comsume others service ( whose implementation is HTTP Authentication based )
 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Axis2 does not support Rampart with JAX-WS service so we need to do HTTP or manual authentication.
 
Ranch Hand
Posts: 734
7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Axis2 does not support Rampart with JAX-WS service so we need to do HTTP or manual authentication.


Apart from this thread being 2 years old, I don't know, that statement can't be serious, can it? even if we put ourselves back to the time of year 2010.
http://axis.apache.org/axis2/java/rampart/
Maybe I miss the point?
 
He was giving me directions and I was powerless to resist. I cannot resist this tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic