xfire代理调用:
public static void main(String[] args) {
//创建服务的元数据
Service serviceModel=new ObjectServiceFactory().create(Ihello.class);
//创建服务代理
XFire xfire=XFireFactory.newInstance().getXFire();
XFireProxyFactory factory = new XFireProxyFactory(xfire);
//服务地址
String serviceUrl="http://localhost:8088/service/services/hello";
//服务代理通过服务元数据和服务地址取得服务实例
try {
Ihello helloService=(Ihello)factory.create(serviceModel, serviceUrl);
String helloResponse=helloService.sayHello("张三");//-1,0,1<
System.out.println("服务器返回的结果是:"+helloResponse);
} catch (MalformedURLException e) {
e.printStackTrace();
}
}
RPC远程过程调用:
public static void main(String[] args) {
//创建服务的元数据
Service serviceModel=new ObjectServiceFactory().create(Ihello.class);
//创建服务代理
XFire xfire=XFireFactory.newInstance().getXFire();
XFireProxyFactory factory = new XFireProxyFactory(xfire);
//服务地址
String serviceUrl="http://localhost:8088/service/services/hello";
//服务代理通过服务元数据和服务地址取得服务实例
try {
Ihello helloService=(Ihello)factory.create(serviceModel, serviceUrl);
String helloResponse=helloService.sayHello("张三");//-1,0,1<
System.out.println("服务器返回的结果是:"+helloResponse);
} catch (MalformedURLException e) {
e.printStackTrace();
}
}