1.xfire服务器配置
1.1 web.xml
<servlet>
<servlet-name>xfire</servlet-name>
<servlet-class>org.codehaus.xfire.spring.XFireSpringServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>xfire</servlet-name>
<url-pattern>/services/*</url-pattern>
</servlet-mapping>
1.2 remote-client.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns:task="http://www.springframework.org/schema/task"
xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-2.5.xsd">
<!-- 在spring的配置文件中配置hession工厂代理类 -->
<bean id="myServiceClient"
class="org.springframework.remoting.caucho.HessianProxyFactoryBean">
<property name="serviceUrl">
<value>http://XXXX:8880/RiskControl/logPersonHessian
</value>
</property>
<property name="serviceInterface">
<value>com.cmsz.rc.services.WarnInfoService</value>
</property>
</bean>
</beans>
1.3 applicationContext-webservice.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">
<import resource="classpath:org/codehaus/xfire/spring/xfire.xml" />
<bean id="xfireExporter" class="org.codehaus.xfire.spring.remoting.XFireExporter">
<!-- <property name="serviceFactory" ref="xfire.serviceFactory" /> -->
<property name="xfire" ref="xfire" />
<property name="serviceBean" ref="xtgdWebService"/>
<property name="serviceClass" value="com.cmsz.rc.services.XtgdWebService" />
<property name="name" value="myWebService" />
</bean>
</beans>
2.xfire客户端
2.1 web.xml
<servlet>
<servlet-name>xfire</servlet-name>
<servlet-class>org.codehaus.xfire.spring.XFireSpringServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>xfire</servlet-name>
<url-pattern>/services/*</url-pattern>
</servlet-mapping>
2.2 remote-servlet.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns:task="http://www.springframework.org/schema/task"
xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd">
<bean id="warnInfoService" class="com.cmsz.rc.services.impl.WarnInfoServiceImpl" />
<!-- hessionServiceExporter作用将一个常规 bean 导出成 Hessian 服务。 -->
<bean name="/logPersonHessian"
class="org.springframework.remoting.caucho.HessianServiceExporter">
<property name="service">
<ref bean="warnInfoService" />
</property>
<property name="serviceInterface">
<value>com.cmsz.rc.services.WarnInfoService</value>
</property>
</bean>
</beans>
调用方法:
String url="http://XXXX/services/xtgdWebService?wsdl"; //工单系统接口路径
Client c1=new Client(new URL(url));
Object[] o1=c1.invoke("startToCreateItem4ITbyFK",new String[]{String.valueOf(workNumber),title,context,finishTime,inSystem,"","","","","",mainHandlePerson,department,""});
注意事项:
1.客户端和服务器端需要对接的实体类,路径得保持一致
2.字段都需要使用序列化的类型,如int不能用int,只能用Integer,具体如何叫序列化,这里就不过多的描述勒。