例如:
1,服务端:XFireServlet-servlet.xml
2,客户端调整原spring注入配置文件
原来:
采用xfire后修改注入方式:
调整完配置文件后,java还是跟原来方式一样无需改动
如果不修改注入文件,调用方式如下:
1,服务端:XFireServlet-servlet.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN"
"http://www.springframework.org/dtd/spring-beans.dtd">
<beans>
<bean
class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
<property name="urlMap">
<map>
<entry key="/CompanyWebServices">
<ref bean="company" />
</entry>
</map>
</property>
</bean>
<bean id="company"
class="org.codehaus.xfire.spring.remoting.XFireExporter">
<property name="serviceFactory">
<ref bean="xfire.serviceFactory" />
</property>
<property name="xfire">
<ref bean="xfire" />
</property>
<property name="serviceBean">
<ref bean="companyWebServices" />
</property>
<property name="serviceClass">
<value>com.xxx.demo.platform.company.service.spring.HelloWebServiceImpl</value>
</property>
</bean>
</beans>
2,客户端调整原spring注入配置文件
原来:
<bean id="helloWebService"
class="com.xxx.demo.platform.company.service.spring.HelloWebServiceSpringImpl" />
采用xfire后修改注入方式:
<bean id="helloWebService" class="org.codehaus.xfire.spring.remoting.XFireClientFactoryBean">
<property name="serviceClass">
<value>com.xxx.demo.platform.company.service.facade.HelloWebService</value>
</property>
<property name="wsdlDocumentUrl">
<value> http://localhost:8080/xxx/webservice/CompanyWebServices?WSDL</value>
</property>
</bean>
调整完配置文件后,java还是跟原来方式一样无需改动
...
helloWebService.XXX();
...
如果不修改注入文件,调用方式如下:
//call webservice
Service srvcModel = (Service) new ObjectServiceFactory().create(HelloWebService.class);
XFireProxyFactory factory = new XFireProxyFactory(XFireFactory
.newInstance().getXFire());
String helloWorldURL;
logger.debug("查看机构信息");
helloWorldURL = "url";
try {
HelloWebService srvc = (HelloWebService) factory.create(srvcModel, helloWorldURL);
reComCode = srvc.sayHello(ComCode);
} catch (MalformedURLException e) {
e.printStackTrace();
}