Spring中整合Xfire发布webservice服务

一、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>









  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值