微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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();
		}
	
    

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐