1.web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<display-name>XFireWebservice</display-name>
<!-- Spring配置 -->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:org/codehaus/xfire/spring/xfire.xml,classpath:applicationContext.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<!-- XFire 配置 -->
<servlet>
<servlet-name>xfireServlet</servlet-name>
<servlet-class>org.codehaus.xfire.spring.XFireSpringServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>xfireServlet</servlet-name>
<url-pattern>/service/*</url-pattern>
</servlet-mapping>
</web-app>
2.在classpath下新建applicationContext.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"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">
<bean id="sendMailService" class="com.deng.webservice.first.SendEmailImpl" />
<bean id="sendMail" class="org.codehaus.xfire.spring.ServiceBean">
<property name="serviceBean" ref="sendMailService" /> <!-- 实现 -->
<property name="serviceClass" value="com.deng.webservice.first.SendEmail" /> <!-- 接口 -->
<property name="inHandlers">
<list>
<ref bean="addressingHandler" />
</list>
</property>
</bean>
<bean id="addressingHandler" class="org.codehaus.xfire.addressing.AddressingInHandler" />
</beans>
3.依赖的jar包
commons-beanutils-1.7.0.jar
commons-codec-1.3.jar
commons-httpclient-3.0.jar
commons-logging-1.0.4.jar
jdom-1.0.jar
spring.jar
wsdl4j-1.6.1.jar
xfire-all-1.2.6.jar
4.如何访问
http://localhost:8080/${工程名}/service/SendEmail?wsdl
http://localhost:8080/${工程名}/service/