Win a copy of Secure Financial Transactions with Ansible, Terraform, and OpenSCAP this week in the Cloud/Virtualization forum!
  • 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
  • Ron McLeod
  • Paul Clapham
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Rob Spoor
  • Henry Wong
  • Liutauras Vilda
Saloon Keepers:
  • Tim Moores
  • Carey Brown
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
Bartenders:
  • Frits Walraven
  • Himai Minh
  • Jj Roberts

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

 
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 548
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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", "??");
 
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 1067
2
IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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", "??");

 
Here. Have a potato. I grew it in my armpit. And from my other armpit, this tiny ad:
SKIP - a book about connecting industrious people with elderly land owners
https://coderanch.com/t/skip-book
reply
    Bookmark Topic Watch Topic
  • New Topic