This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Soft Skills and have John Sonmez on-line!
See this thread for details.
The moose likes Web Services and the fly likes How do you create a webservice client using WSDL2Java which uses SSL? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Web Services
Bookmark "How do you create a webservice client using WSDL2Java which uses SSL?" Watch "How do you create a webservice client using WSDL2Java which uses SSL?" New topic
Author

How do you create a webservice client using WSDL2Java which uses SSL?

prem saggar
Ranch Hand

Joined: Aug 24, 2000
Posts: 66
Hi everyone. I'm trying to create a webservice client using wsdl2java and it must comunicate with the webservice via SSL. I have the keystores set up for this. How do I get WSDL2Java to generate https ready code using my keystores? Thanks, guys.


Prem
Rr Kumaran
Ranch Hand

Joined: Sep 17, 2001
Posts: 548
there is nothing like ready code.

1. Import the server certificats in ur client truststore,
2. run wsdl2java on https endpoint and generate the stubs
3. set below properties in ur client program

System.setProperty("java.protocol.handler.pkgs", "com.sun.net.ssl.internal.www.protocol");

Security.addProvider (new com.sun.net.ssl.internal.ssl.Provider());

System.setProperty("javax.net.ssl.trustStore", "<trust store location>");
System.setProperty("javax.net.ssl.trustStoreType", "jks | JCEKS");
System.setProperty("javax.net.ssl.trustStorePassword", "??");
System.setProperty("javax.net.ssl.keyStoreType", "jks");
System.setProperty("javax.net.ssl.keyStore", "<trust store location>");
System.setProperty("javax.net.ssl.keyStorePassword", "??");


RR Kumaran
SCJP 1.4
Peter Hu
Ranch Hand

Joined: Apr 15, 2005
Posts: 33
If the keystore has more than one key, which one will be used for the communication with the server?
prem saggar
Ranch Hand

Joined: Aug 24, 2000
Posts: 66
I agree with the question above. Which key is used in the keystore if there are multiple keys? Thanks for all the help. Prem
William Barnes
Ranch Hand

Joined: Mar 16, 2001
Posts: 986

You only want one key per keystore/truststore.


Please ignore post, I have no idea what I am talking about.
Peter Hu
Ranch Hand

Joined: Apr 15, 2005
Posts: 33
My application needs to connect with a couple of different web services servers at the same time. I have to use multiple certificates. How do my web services client knows which one to pick?
philber fang
Greenhorn

Joined: Dec 30, 2004
Posts: 12
Hi RR Kumaran and others,

If the client is not a standalone java client, but a servlet running on Websphere 5, is it still the same that I just set the properties you mentioned below in my servlet calling the web services?

All any one knows the steps to set this(client only) up in websphere? Since the JVM is in the container though.

Thanks in advance!!!

Originally posted by RR Kumaran:
there is nothing like ready code.

1. Import the server certificats in ur client truststore,
2. run wsdl2java on https endpoint and generate the stubs
3. set below properties in ur client program

System.setProperty("java.protocol.handler.pkgs", "com.sun.net.ssl.internal.www.protocol");

Security.addProvider (new com.sun.net.ssl.internal.ssl.Provider());

System.setProperty("javax.net.ssl.trustStore", "<trust store location>");
System.setProperty("javax.net.ssl.trustStoreType", "jks | JCEKS");
System.setProperty("javax.net.ssl.trustStorePassword", "??");
System.setProperty("javax.net.ssl.keyStoreType", "jks");
System.setProperty("javax.net.ssl.keyStore", "<trust store location>");
System.setProperty("javax.net.ssl.keyStorePassword", "??");
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How do you create a webservice client using WSDL2Java which uses SSL?