简单记录一下 刚写的webservice simple demo

1、首先需要下在xfire jar包。[url]http://grails.org/plugin/xfire[/url]
2、配置web.xml
(1) 启动的时候可以加载到配置文件 (认为可以吧xfire-servlet 放到 context 配置文件中,待测试)
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
/WEB-INF/spring.xml,/WEB-INF/xfire-servlet.xml
</param-value>
</context-param>
(2)配置servlet
<servlet>
<servlet-name>xfire</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
</servlet>

<!-- 配合Spring容器中XFire一起工作的Servlet-->
<servlet>
<servlet-name>xfireServlet</servlet-name>
<servlet-class>org.codehaus.xfire.spring.XFireSpringServlet</servlet-class>
</servlet>


<servlet-mapping>
<servlet-name>xfire</servlet-name>
<url-pattern>*.ws</url-pattern>
</servlet-mapping>

<servlet-mapping>
<servlet-name>xfireServlet</servlet-name>
<!-- 在这个URI下开放Web Service服务 -->
<url-pattern>/service/*</url-pattern>
</servlet-mapping>
3、配置 xfire-servlet.xml
<!-- 引入XFire预配置信息 -->
<import resource="classpath:org/codehaus/xfire/spring/xfire.xml"/>

<!-- 使用XFire导出器 -->
<bean id="baseWebService" class="org.codehaus.xfire.spring.remoting.XFireExporter" lazy-init="false" abstract="true">
<!-- 引用xfire.xml中定义的工厂 -->
<property name="serviceFactory" ref="xfire.serviceFactory"/>
<!-- 引用xfire.xml中的xfire实例 -->
<property name="xfire" ref="xfire"/>
</bean>

<!-- 定义所有访问 WEB服务的url -->
<bean class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
<property name="urlMap">
<map>
<entry key="/HelloWorldService.ws"><ref local="HelloWorldService"/></entry>
</map>
</property>
</bean>

<!-- HelloWorld WEB服务 -->
<bean id="HelloWorld" class="com.test.webservice.impl.SayHelloImpl"/>
<bean id="HelloWorldService" parent="baseWebService">
<!-- 业务服务bean -->
<property name="serviceBean" ref="HelloWorld"/>
<!-- 业务服务bean的窄接口类 -->
<property name="serviceClass" value="com.test.webservice.SayHello"/>
</bean>
到这里服务端的配置 就完成了。
4、配置 client.xml
<bean id="HelloWorldService" class="org.codehaus.xfire.spring.remoting.XFireClientFactoryBean">
<property name="serviceClass"><value>com.test.webservice.SayHello</value></property>
<property name="wsdlDocumentUrl"><value>http://10.108.108.106:9090/webservice/HelloWorldService.ws?wsdl</value></property>
<!-- 在系统启动时,spring不立即查找远程的服务Bean,而在请求该服务时查找 -->
<property name="lookupServiceOnStartup"><value>false</value></property>
</bean>
5.远程调用即可

以上均出自别人 博客 ,自己实现一下 再次感谢写博客的兄弟了 。
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值