webservice

可能会用到的调用web service的客户端代码

/*
        JaxWsProxyFactoryBean proxyFactoryBean=new JaxWsProxyFactoryBean();
        //设置访问地址
        proxyFactoryBean.setAddress("http://127.0.0.1:8089/user?wsdl");
        //设置portType
        proxyFactoryBean.setServiceClass(IUsersService.class);
        //获取服务对象
        IUsersService usersService= (IUsersService) proxyFactoryBean.create();
        usersService.getAge("李白");

        Client client = new Client(new URL("http://127.0.0.1:8089/user?wsdl"));
        Object[] results = client.invoke("getAge", new Object[] { "李白" });
        System.out.println(results[0]);*/

    }

        /*try {
            String endpoint = "http://localhost:8088/weather"; //直接引用远程的wsdl文件
            Service service = new Service();
            Call call = (Call) service.createCall();
            call.setTargetEndpointAddress(endpoint);
            //call.setOperationName("getName");//wsdl里面描述的接口名称
            call.addParameter("userId", XMLType.XSD_DATE, ParameterMode.IN);//接口的参数
            call.setReturnType(XMLType.XSD_STRING);//设置返回类型
            call.invoke("getName",new Object[]{10001});//给方法传递参数,并且调用方法
           // System.out.println("result is " + result);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }*/


}

  /*      JaxWsDynamicClientFactory dcf = JaxWsDynamicClientFactory.newInstance();
        Client client = dcf.createClient("http://192.168.122.71:8000/services/resourceService?wsdl");
        Object[] objects = new Object[0];
        String param="\n" +
                "\n" +
                "  \n" +
                "    \n" +
                "      <idcCenterCode>Mega_IDC_4</idcCenterCode>\n" +
                "    \n" +
                "  \n" +
                "";
        try {
            objects = client.invoke("queryRoom",  param);
        } catch (Exception e) {
            e.printStackTrace();
        }
//输出调用结果
        System.out.println(objects[0].getClass());
        System.out.println(objects[0].toString());
    }*/
    

你可能感兴趣的:(webservice)