在开发环境中,自己搭建一个ssl环境(小例子)

 

做项目的时候自己总结的一些小例子

public class Test {

 

public static void setSSLProperty() {

Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider());

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("java.protocol.handler.pkgs",

"com.sun.net.ssl.internal.www.protocol");

System.setProperty("javax.net.ssl.keyStore", "****.pfx");//私钥的全路径

System.setProperty("javax.net.ssl.trustStore",

"****/****");//配置文件的全路径

System.setProperty("javax.net.ssl.trustStorePassword", "changeit");

System.setProperty("javax.net.ssl.keyStorePassword", "123456");

System.setProperty("javax.net.ssl.keyStoreType", "pkcs12");

System.setProperty("javax.net.ssl.trustStoreType", "jks");

}

 

public static void main(String[] args) {

setSSLProperty();

try {

//Web服务地址

String endpoint = "https://pay.test.bank.ecitic.com/Payment/services/PaymentServices";

Service service = new Service();

Call call = (Call) service.createCall();

call.setTargetEndpointAddress(endpoint);

call.setMaintainSession(true);

call.setOperationName("login");

call.addParameter("paraXML", org.apache.axis.Constants.XSD_STRING,

javax.xml.rpc.ParameterMode.IN);

call.setReturnType(org.apache.axis.Constants.XSD_STRING);

call.setUseSOAPAction(true); call.setSOAPActionURI("http://service.payment.citiccard.com");

String login = “发送的内容”;

String resultA = (String) call.invoke(new Object[] { login });

//输出一个返回的结果

System.out.println("login result is " + resultA);

posted @ 2016-03-30 09:52  ~铁臂阿童木~  阅读(1635)  评论(0编辑  收藏  举报