Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
prem saggar
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 548
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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", "??");
 
Peter Hu
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If the keystore has more than one key, which one will be used for the communication with the server?
 
prem saggar
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 986
Eclipse IDE Firefox Browser Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You only want one key per keystore/truststore.
 
Peter Hu
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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", "??");
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic