zoukankan      html  css  js  c++  java
  • [转贴]Java客户端调用Https Webservice

    标题: Java客户端调用Https Webservice
    出处地址:http://hi.baidu.com/sunshibing/blog/item/08f873f0d41e67c37931aa84.html

    Java 要调用远程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.
  • 相关阅读:
    NEFU84——五指山(Exgcd)
    Scoi2010——传送带(三分套三分=九分)
    POJ3352Road construction(边双联通分量)
    CEOI2005——关键网线(割边)
    ZJOI2004——嗅探器
    POJ1845s——Sumdiv()
    Web 服务器安全
    渗透测试神器Cobalt Strike的使用
    Windows中的用户和组以及用户密码处理
    漏洞及渗透练习平台 【大全】
  • 原文地址:https://www.cnblogs.com/sun_moon_earth/p/706961.html
Copyright © 2011-2022 走看看