可能会用到的调用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="<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" +
"<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:soapenc=\"http://schemas.xmlsoap.org/soap/encoding/\" xmlns:tns=\"http://serv.services.rs.idc.regaltec.com\" xmlns:types=\"http://serv.services.rs.idc.regaltec.com/encodedTypes\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">\n" +
" <soap:Body soap:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\">\n" +
" <tns:queryRoom>\n" +
" <inputXml xsi:type=\"xsd:string\"><idcCenterCode>Mega_IDC_4</idcCenterCode></inputXml>\n" +
" </tns:queryRoom>\n" +
" </soap:Body>\n" +
"</soap:Envelope>";
try {
objects = client.invoke("queryRoom", param);
} catch (Exception e) {
e.printStackTrace();
}
//输出调用结果
System.out.println(objects[0].getClass());
System.out.println(objects[0].toString());
}*/