xfire+spring 实践记录(二)

xfire+spring 实践记录(一)
客户端代码:
1、将服务端的com.sap.jco.ws.WebServiceSAP.java接口copy到本地
2、新增spring的applicationcontext
applicationContext-client.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">

<beans  default-lazy-init="true">
<bean id="sapWebService" class="org.codehaus.xfire.spring.remoting.XFireClientFactoryBean">
<property name="serviceClass">
<value>com.sap.jco.ws.WebServiceSAP</value>
</property>
<property name="wsdlDocumentUrl">
<value>http://127.0.0.1:88/wssap/services/SAPService?WSDL</value>
</property>
</bean>
</beans>

3、applicationContext.xml中增加
<import resource="classpath:org/codehaus/xfire/spring/xfire.xml" />  
<import resource="applicationContext-client.xml"/>

4、调用:
TestService client=(TestService)ServiceFactory.getBeanByName("testWebService");
    Map map=client.add(new HashMap(), 1, 2);
    System.out.println("map value:"+map.get("p3"));
可以返回结果

你可能感兴趣的:(spring,bean,xml)