Title: Java client calls HTTPS WebService
Source Address: http://hi.baidu.com/sunshibing/blog/item/08f873f0d41e67c37931aa84.html
Java must use the client trust book and key provided by the remote server to call the remote HTTPS WebService.
Copy client. keystore and client. truststore to the classes \ test directory.
Package test;
Import org. Apache. axis. Client. call;
Import org. Apache. axis. Client. Service;
Public class testecvotenotice
{
Public static void main (string [] ARGs) throws exception {
System. setproperty ("javax.net. SSL. keystore", "test \ Client. keystore ");
System. setproperty ("javax.net. SSL. keystorepassword", "ABC ");
System. setproperty ("javax.net. SSL. truststore", "test \ Client. truststore ");
System. setproperty ("javax.net. SSL. truststorepassword", "ABC ");
// System. setproperty ("javax.net. debug", "SSL ");
// System. setproperty ("HTTPS. Protocols", "tlsv1 ");
// System. setproperty ("Java. Protocol. handler. pkgs", "javax.net. SSL ");
String endpoint = "https: // localhost:" + "8443" + "/axis/services/ecvotenotice ";
// String endpoint = "http: // localhost:" + "8080" + "/axis/services/ecvotenotice ";
Service = new service ();
Call call = (CALL) service. createcall ();
Call. settargetendpointaddress (New java.net. URL (endpoint ));
Call. setoperationname ("tostringp ");
String res = (string) Call. Invoke (new object [] {"box "});
Call. setoperationname ("tostring ");
String RES2 = (string) Call. Invoke (new object [] {});
System. Out. println (RES + "/" + RES2 );
}
}
Run in the classes directory.
Java-CP % axisclasspath % test. testecvotenotice
OK.