//创建天气预报web服务的元数据
// Creates Services from java objects.
// This class is meant to be easily overridable so you can customize
// how your services are created.
//create(java.lang.Class clazz)
//Creates a service from the specified class. 从一个具体类创建服务
//Service代表一个服务的端点,一个服务是专门处理xml信息
//Service Represents a service endpoint. A service's sole job is to process xml messages.
//1:
Service service = new ObjectServiceFactory().create(IgetWeather.class);
//创建web服务的代理
//The XFireFactory class allows you to embed XFire within your apps easily.
//XFireFactory类允许你很容易的嵌入XFire到你的应用里
//This class assumes one XFire instance per JVM.虚拟机里面允许有一个XFire实例化对象
//To create many XFire instances you must use your own configuration and instantiation mechanism.
//想要创建更多的XFire实例化对象你必须用你自己的配置和实例化的结构
//2:
XFire xFire = XFireFactory.newInstance().getXFire();
//XFireProxyFactory解释:
//SOAP 是基于 XML 的简易协议,可使应用程序在 HTTP 之上进行信息交换。SOAP 是用于访问网络服务的协议。
// Factory for creating XFire SOAP client stubs. The returned stub will call the remote object for all methods.
// Service serviceModel = new ObjectServiceFactory().create(Echo.class);
// String url = "http://localhost:8080/services/Echo");
// Echo echo = (Echo) factory.create(serviceModel, url);
//3:
XFireProxyFactory factory = new XFireProxyFactory(xFire);
//获取天气预报的web服务的地址
String url = "http://localhost:7777/mywebService/services/Weather";
//生成天气预报web服务调用对象
//4:
try {
IgetWeather ig = (IgetWeather) factory.create(service, url);
System.out.println(ig.hello());
} catch (MalformedURLException e) {
e.printStackTrace();
}
如有不对 请包涵