一、web.xml中配置xfire的servlet交由spring管理
<!-- Context Configuration locations for Spring XML files -->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/applicationContext-*.xml</param-value>
</context-param>
<listener>
<listener-class>
org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>
<!-- Xfire Servlet -->
<servlet>
<servlet-name>XFireServlet</servlet-name>
<display-name>XFire Servlet</display-name>
<servlet-class>org.codehaus.xfire.spring.XFireSpringServlet</servlet-class>
<!-- 不整合时使用org.codehaus.xfire.transport.http.XFireConfigurableServlet -->
</servlet>
<servlet-mapping>
<servlet-name>XFireServlet</servlet-name>
<url-pattern>/services/*</url-pattern>
</servlet-mapping>
二、applicationContext-webservice.xml配置需发布的class相关配置文件
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
<beans>
<!-- 引入xfire.xml-->
<import resource="classpath:org/codehaus/xfire/spring/xfire.xml" />
<bean id="helloServiceImpl" class="com.sasis.webservice.HelloServiceImpl"/>
<bean id="helloService" class="org.codehaus.xfire.spring.ServiceBean">
<property name="serviceBean" ref="helloServiceImpl"/>
<property name="serviceClass" value="com.sasis.webservice.HelloServiceImpl"/>
</bean>
</beans>
三、调用时用类名HelloServiceImpl,浏览器访问http://localhost/ProjectName/services/HelloServiceImpl?wsdl可得到如下类似的webservice文件
<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions targetNamespace="http://webservice.sasis.com" xmlns:soapenc12="http://www.w3.org/2003/05/soap-encoding" xmlns:tns="http://webservice.sasis.com" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap11="http://schemas.xmlsoap.org/soap/envelope/" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:soapenc11="http://schemas.xmlsoap.org/soap/encoding/" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
<wsdl:types>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://webservice.sasis.com">
<xsd:element name="saveOrUpdateUpgradeVoucherInfo">
<xsd:complexType>
<xsd:sequence>
<xsd:element maxOccurs="1" minOccurs="1" name="xmlParam" nillable="true" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="saveOrUpdateUpgradeVoucherInfoResponse">
<xsd:complexType>
<xsd:sequence>
<xsd:element maxOccurs="1" minOccurs="1" name="out" nillable="true" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
</wsdl:types>
<wsdl:message name="saveOrUpdateUpgradeVoucherInfoResponse">
<wsdl:part name="parameters" element="tns:saveOrUpdateUpgradeVoucherInfoResponse"/>
</wsdl:message>
<wsdl:message name="saveOrUpdateUpgradeVoucherInfoRequest">
<wsdl:part name="parameters" element="tns:saveOrUpdateUpgradeVoucherInfo"/>
</wsdl:message>
<wsdl:portType name="UpgradeVoucherServiceImplPortType">
<wsdl:operation name="saveOrUpdateUpgradeVoucherInfo">
<wsdl:input name="saveOrUpdateUpgradeVoucherInfoRequest" message="tns:saveOrUpdateUpgradeVoucherInfoRequest"/>
<wsdl:output name="saveOrUpdateUpgradeVoucherInfoResponse" message="tns:saveOrUpdateUpgradeVoucherInfoResponse"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="UpgradeVoucherServiceImplHttpBinding" type="tns:UpgradeVoucherServiceImplPortType">
<wsdlsoap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="saveOrUpdateUpgradeVoucherInfo">
<wsdlsoap:operation soapAction=""/>
<wsdl:input name="saveOrUpdateUpgradeVoucherInfoRequest">
<wsdlsoap:body use="literal"/>
</wsdl:input>
<wsdl:output name="saveOrUpdateUpgradeVoucherInfoResponse">
<wsdlsoap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="UpgradeVoucherServiceImpl">
<wsdl:port name="UpgradeVoucherServiceImplHttpPort" binding="tns:UpgradeVoucherServiceImplHttpBinding">
<wsdlsoap:address location="http://localhost:8080/scsis/services/UpgradeVoucherServiceImpl"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>