• Post Reply Bookmark Topic Watch Topic
  • New Topic

Tomcat axis2 web service with HTTPS

 
Chris Chenier
Greenhorn
Posts: 2
Eclipse IDE Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I'm trying to get a tomcat/axis2 web service working over HTTPS.
I know this has been ask over and over but I haven't (yet) found the solution.

To keep things clear I've created a web service that simply add two integers together and returns the sum.

Relevant info:
Eclipse Indigo
Axis 2 (2-1.6.1)
Tomcat 6:
-with keytool created certificate in the ${user.home}./keystore file:
- server.xml has:


Basically I followed these instructions: Tomcat6_SSL_HOW_TO


So, first things first I create the addNums web service :


Eclipse creates the WebContent directory with the following relevant files:

WebContent\WEB-INF\services\addNums\META-INF\services.xml:


WebContent\WEB-INF\web.xml:


At this point I can access the main web service page with https
https://localhost:8443/AddNumbers/

But if I click on the 'Services' link I get the error "https is forbidden"

To fix that I add the following the the /WebContent/WEB-INF/conf/axis2.xml file:


I restart tomcat and I can get to the 'Services' page (https://localhost:8443/AddNumbers/services/listServices)
It correctly shows my addNums web service. I can click on that link to get the WSDL (https://localhost:8443/AddNumbers/services/addNums?wsdl)

All good so far.

Using the Eclipse wizard I create a web service client to test.
AddNumbersClient
- AddNumsCallbackHandler.java
- AddNumsStub.java
- AddNumbersClient.java (manually created by me and calls stub.addNumbers(Numbers); with the numbers 41 and 1)

I run this as a 'Java application' and the console windows displays the answer 42.
Good.

Then I edit AddNumsStub.java to change:
this(configurationContext,"http://localhost:8080/AddNumbers/services/addNums.addNumsHttpSoap11Endpoint/" );
to
this(configurationContext,"https://localhost:8443/AddNumbers/services/addNums.addNumsHttpSoap11Endpoint/" );

and rerun the client. This time I get errors:



So, what else do I need to do to get HTTPS to work? I'm guessing it has something to do with the WSDL file but I'm stuck.

Any ideas?

Thanks
Chris




 
Chris Chenier
Greenhorn
Posts: 2
Eclipse IDE Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Found the solution.

The problem was:
PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target

I needed to import the certificate on my client machine (even on the server in fact for the client to work):

keytool -export -keystore .keystore -alias tomcat -file localhost.cer

Then I did an import of the above certificate into client machine:

keytool -import -alias tomcat -file localhost.cer -keystore "C:\Program Files"\Java\jdk1.6.0_17\jre\lib\security\cacerts"


Now the client (addNumsClient.jar) runs on any machine that has this certificate.

 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!