axis2.1.4 访问https webservices

1: 首先把证书导出

   

       点击这把锁的标识,弹出

  

   查看证书

点导出,生在一个myKey.cer 文件

2:然后根据这个.CER文件生成.trustStore 文件

   keytool -import -file f:/myKey.cer -storepass netconfig -keystore f:/crtTrust.trustStore config -noprompt

3: 在需要用倒的地方加上

      System.setProperty("javax.net.ssl.trustStore","f:/crtTrust.trustStore");
      System.setProperty("javax.net.ssl.trustStorePassword", "netconfig");
4:如果服务器端需要用户名的密码验证,那得把用户名和密码传进去

        System.setProperty("javax.net.ssl.trustStore","f:/crtTrust.trustStore");
        System.setProperty("javax.net.ssl.trustStorePassword", "netconfig"); 


        /**
         * keytool -import -file f:/net.cer -storepass netconfig -keystore f:/crt1.trustStore  -noprompt
         * 生成 f:/crt1.trustStore 和 f:/crt 这两个文件都行。
         */
        
        try
        {
            RPCServiceClient serviceClient = new RPCServiceClient();
            Options option = serviceClient.getOptions();

            // http://localhost:8087/HelloWord 访问 WSDL的路径名称
            //https://localhost:8080/server/security?wsdl
            EndpointReference tReference = new EndpointReference("https://localhost:8080/server/launchers?wsdl");
            option.setTo(tReference);
           
            Authenticator authenticator = new Authenticator();

            List<String> auth = new ArrayList<String>();

            auth.add(Authenticator.BASIC);

            authenticator.setAuthSchemes(auth);

            authenticator.setUsername("admin");

            authenticator.setPassword("password");

            authenticator.setPreemptiveAuthentication(true);

            option.setProperty(HTTPConstants.AUTHENTICATE, authenticator);
           
            

            
         
            
            // 指定 sayHello 方法的参数 返回值对象
            Class[] classes = new Class[] { List[].class };

            //调用sayHello 的方法 及 WSDL 的命名空间  (注意:是WSDL中的namespace 属性 (在这里犯了一个大错))
            
            // http://www.netconfig.org/server/security   listUsers
            QName qName = new QName("http://www.netconfig.org/server/launchers", "getLaunchers");

            /**
             * qName :表示方法名
             * 
             * opAddEntryArgs :参数类型 object[]
             * 
             * classes :返回值 类型 class
             */
            Object[] obj = serviceClient.invokeBlocking(qName, new Object[] {}, classes);

            List[] list_arr = (List[])obj[0];
			
			
			for (int i= 0 ; i < list_arr.length; i ++)
			{
				
				List list_ =  list_arr[i];
				
				for (int j = 0 ; j < list_.size() ;j ++)
				{
				 OMElementImpl omElementImpl = (OMElementImpl)list_.get(j);
				 System.out.println("localname--"+omElementImpl.getLocalName());
				 System.out.println("text--"+omElementImpl.getText());
				 
				}
				
				
				//System.out.println("str---"+string_arr[i]);
						
				
			}
			
            
            
            
            
		}
		catch (Exception e){
			
		e.printStackTrace();
		}
	

    


 


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值