jQuery in Action, 2nd edition*
The moose likes Web Services and the fly likes SSL Web Service Client Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Web Services
Bookmark "SSL Web Service Client" Watch "SSL Web Service Client" New topic
Author

SSL Web Service Client

Bernhard Haeussermann
Ranch Hand

Joined: Aug 05, 2009
Posts: 38
Hi. I have a SSL web service running on a Glassfish application server.
After registering the certificate, I managed to write a client in .NET.
However, I need to get a client working in Java.
Here are my attempts:
When I try to add a web service reference to a Dynamic Web Project in Eclipse using the New Web Service Client wizard, it tells me "The service definition selected is invalid" when I enter the address https://ec2-175-129-234-13.compute-1.amazonaws.com:8181/secureservice/SecureService?wsdl.
When I execute the Ant-script



I get the following error:


Certainly I must tell the client stub generator where it can find the certificate (?). How should I go about this?

Thanks in advance.
Ivan Krizsan
Ranch Hand

Joined: Oct 04, 2006
Posts: 2198
    
    1
Hi!
Is it a requirement that clients have to access the WSDL using SSL?
If not, you may consider applying SSL to the web service calls, but allowing normal HTTP access of the WSDL.
Actually, JSR-109 in section 9.3.2 specifies that only POST requests are to be protected by SSL in JAX-RPC and JAX-WS web services, thus GET requests used to retrieve the WSDL should not be protected by SSL.
To accomplish this, you specify the security constraints for the web service in the web.xml deployment descriptor as in this exampleÖ

Best wishes!
Bernhard Haeussermann
Ranch Hand

Joined: Aug 05, 2009
Posts: 38
Hi Ivan.

No, it's not necessary that the WSDL has to be accessed using SSL.
However, when I deploy the web service omitting in the web.xml file, I get errors in the clients when I do a test web service call (however, the client stub code generation is successful).
The .NET client that worked before (with <http-method>GET</http-method>) throws the following exception when I do a web service call:



A web service call in Java with the Axis client stubs (via the Add New Web Service Client wizard) yields:



When I generate the client stubs with wsimport (that Ant-file) I get


Ivan Krizsan
Ranch Hand

Joined: Oct 04, 2006
Posts: 2198
    
    1
Bernhard Haeussermann wrote:
However, when I deploy the web service omitting in the web.xml file, I get errors in the clients when I do a test web service call

As before, you should not omit the <http-method> specification, but change it to <http-method>POST</http-method>.
With this configuration, GET requests retrieving the WSDL will not be encrypted, and you can generate client artifacts using wsimport. Requests to the service, which are always HTTP POST requests, will require HTTPS.
Best wishes!
Bernhard Haeussermann
Ranch Hand

Joined: Aug 05, 2009
Posts: 38
Actually, I had two <http-method> specifications - one for POST and one for GET. I just removed the one for GET.
In fact, my web.xml looks just like the one you gave me. Sorry for the misunderstanding.
What else could be wrong? Might there be a problem with my web service?
Ivan Krizsan
Ranch Hand

Joined: Oct 04, 2006
Posts: 2198
    
    1
Hi!
First of all, as a desperate measure , I enclose the complete web.xml deployment descriptor:


Second, it looks strange that your web service replies with text/html when you request the WSDL. Are you able to successfully request the WSDL from a browser? Try using some kind of tool that let you see the HTTP headers and examine them.
Most of my experience is with the Metro web service stack and I have not seen problems like these before.
Good luck!
Bernhard Haeussermann
Ranch Hand

Joined: Aug 05, 2009
Posts: 38
My web.xml looks identical to yours.
Furthermore, there is no problem with retrieving the WSDL.
The three errors above all occur only when I attempt to make a web service call.
Bernhard Haeussermann
Ranch Hand

Joined: Aug 05, 2009
Posts: 38
Ok, I got one step further now. The following blog helped quite a bit: http://blogs.sun.com/andreas/entry/no_more_unable_to_find.
The Axis-generated code works now. Because my web service is currently using a test certificate I had to add it as a trusted certificate to the KeyStore on the client-side.
However, I still get the UnsupportedMediaException with the wsimport code. As it seems to me this is probably the same problem that the .NET client is moaning about.
Any ideas?
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 39551
    
  27
it looks strange that your web service replies with text/html when you request the WSDL. Are you able to successfully request the WSDL from a browser? Try using some kind of tool that let you see the HTTP headers and examine them.

I think this is the key to a solution. Make sure you're not getting back an HTML error page created by the server.
Bernhard Haeussermann
Ranch Hand

Joined: Aug 05, 2009
Posts: 38
.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: SSL Web Service Client
 
Similar Threads
https client certificate
jax-ws wsimport does not work
SSL Web Service Client
https client certificate
Call https .net webservice using Java client