猎艳江湖梦出轨部分:Java客户端调用Https Webservice(ZZ)
来源:百度文库 编辑:偶看新闻 时间:2024/05/11 17:17:53
查看文章 Java客户端调用Https Webservice(ZZ)2007-02-11 22:59Java 要调用远程Https webservice 必需具用远程服务器提供的客户端信任书及密钥.
将client.keystore和client.truststore拷贝到classes\test目录下.
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 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 );
}
}
在classes目录下执行.
java -cp %AXISCLASSPATH% test.TestEcVoteNotice
OK.
将client.keystore和client.truststore拷贝到classes\test目录下.
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 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 );
}
}
在classes目录下执行.
java -cp %AXISCLASSPATH% test.TestEcVoteNotice
OK.
JAVA怎样调用客户端应用程序?
https可以不需验证客户端么?
java调用的问题。
java ftp客户端服务
JAVA调用类的问题。
Java如何调用Windows API
Java如何调用Windows API??????????
JAVA中的递归调用问题
关于java的函数调用~~
JAVA怎么调用摄像头呢?
用JAVA如何调用批处理文件
用java怎样调用批处理文件
ASP如何调用客户端DLL(急)
java怎样调用c写的服务?
java类文件间方法相互调用。
JAVA中怎么进行递归调用
java如何实现调用文本编辑器
如何调用自建的java包
java调用时的环境变量怎么设置?
java调用时的环境变量怎么设置?
关于java中的隐式调用问题
JAVA怎样调用方法里的变量
如何用Java获取客户端MAC地址?
求教:java编写web service客户端