使用XFire在spring中创建webservice

在web-inf/lib中添加下列jar

xfire-all-1.2.6.jar

jdom.jar

wsdl4j-1.5.1.jar

 

ApplicationContext 中加入

<bean name="echoService" class="org.codehaus.xfire.spring.ServiceBean">
    <property name="serviceBean" ref="echo"/>
    <property name="serviceClass" value="org.codehaus.xfire.test.Echo"/>
    <property name="inHandlers">
      <list>
        <ref bean="addressingHandler"/>
      </list>
    </property>
</bean>

<bean id="echo" class="org.codehaus.xfire.test.EchoImpl"/>

<bean id="addressingHandler" class="org.codehaus.xfire.addressing.AddressingInHandler"/>

 

org.codehaus.xfire.test.Echo为要通过WebService暴露的接口类

org.codehaus.xfire.test.EchoImpl为接口类的实现

 

在web.xml中加入

<web-app>
  <servlet>
    <servlet-name>XFireServlet</servlet-name>
    <display-name>XFire Servlet</display-name>
    <servlet-class>
        org.codehaus.xfire.spring.XFireSpringServlet
    </servlet-class>
  </servlet>

  <servlet-mapping>
    <servlet-name>XFireServlet</servlet-name>
    <url-pattern>/servlet/XFireServlet/*</url-pattern>
  </servlet-mapping>

  <servlet-mapping>
    <servlet-name>XFireServlet</servlet-name>
    <url-pattern>/services/*</url-pattern>
  </servlet-mapping>
</web-app>

修改web.xml中的contextConfigLocation

<context-param>
	<param-name>contextConfigLocation</param-name>
	<param-value>classpath:applicationContext.xml,classpath:org/codehaus/xfire/spring/xfire.xml</param-value>
</context-param>

  

 

 

参考:

http://xfire.codehaus.org/Spring%2C+XBean%2C+Servlets+and+more

 

新发现的一篇好文章

java调用webservice XFire

你可能感兴趣的:(spring,Web,bean,webservice,servlet)