Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

HTTPS Client With AXIS2

843833Oct 20 2008
Hi Guys,

I have a axis web service that I want to access via a java client. Now I have managed to successfully connect to it via http, however I am having some trouble connection with https. In addition I am able to view the service wsdl with my browser using https. I am using tomcat 5.5 and axis2. Authentication has been deactivated in the tomcat config. I tried to create a client like so;
public static void main(String[] args) {
		try{

            Hello_ServiceStub stub =
                new Hello_ServiceStub("https://localhost:8443/axis2/services/Hello_Service");

            SayHelloDocument doc = SayHelloDocument.Factory.newInstance();
            SayHello say = doc.addNewSayHello();

            say.setFirstName("Jay");

            SayHelloResponseDocument resp = stub.sayHello(doc);

            System.out.println(resp.getSayHelloResponse().getGreeting());

        } catch(Exception e){
            e.printStackTrace();
            System.err.println("\n\n\n");
        }
	} 
However I get the following error;
org.apache.axis2.AxisFault: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
at org.apache.axis2.AxisFault.makeFault(AxisFault.java:430)
at org.apache.axis2.transport.http.SOAPMessageFormatter.writeTo(SOAPMessageFormatter.java:83)
at org.apache.axis2.transport.http.AxisRequestEntity.writeRequest(AxisRequestEntity.java:84)
at org.apache.commons.httpclient.methods.EntityEnclosingMethod.writeRequestBody(EntityEnclosingMethod.java:499)
at org.apache.commons.httpclient.HttpMethodBase.writeRequest(HttpMethodBase.java:2114)
at org.apache.commons.httpclient.HttpMethodBase.execute(HttpMethodBase.java:1096)
.....
So i changed the code to include some properties like so;
System.setProperty("java.protocol.handler.pkgs",
"com.sun.net.ssl.internal.www.protocol");
Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider());
but that did absolutely nothing! The certificate I created on the server is self-signed. Can anyone give me an example on how to generate a client to access https content from a server that does not require authentication?
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Nov 17 2008
Added on Oct 20 2008
0 comments
951 views