服务器端:
开发接口类和实现类,配置wervice.xml文件,并添加配置文件interfaceName.aegis.xml,里面配置返回数据类型和参数类型,
<?xml version="1.0" encoding= "UTF-8"?>
<mappings>
<mapping >
<method name="getCpbzs" >
<return-type componentType="org.apache.struts.util.LabelValueBean" />
<parameter index= "0" class = "java.lang.String" />
</method>
</mapping >
</mappings>
客户端:
客户端也要有接口类和返回值类型的配置文件,和服务器端一样。
客户端的调用WEbService由原来的Client方法修改为:
org.codehaus.xfire.service.Service
srvcModel = new ObjectServiceFactory().create(CpbzInter.class);
XFireProxyFactory factory = new XFireProxyFactory(XFireFactory.newInstance().getXFire());
String cpbzURL = "http://localhost:8080/aoling/services/Cpbz";
try{
CpbzInter srvc = (CpbzInter) factory.create(srvcModel, cpbzURL);
List cpbzs=srvc.getCpbzs(hibernateconfig);
request.setAttribute( "cpbzs",
cpbzs);
}
catch(MalformedURLException
e){
e.printStackTrace();
}