加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

axis2.1.4 访问https webservices

发布时间:2020-12-17 00:34:15 所属栏目:安全 来源:网络整理
导读:1: 首先把证书导出 ??? ?????? 点击这把锁的标识,弹出 ?? ?? 查看证书 点导出,生在一个myKey.cer 文件 2:然后根据这个.CER文件生成.trustStore 文件 ? ?keytool -import -file f:/myKey.cer -storepass netconfig -keystore f:/crtTrust.trustStore confi

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

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读