歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux編程 >> Linux編程 >> Spring CXF 整合 發布WebService

Spring CXF 整合 發布WebService

日期:2017/3/1 9:51:57   编辑:Linux編程

web.xml引入CXF和Spring
<?xmlversion="1.0"encoding="UTF-8"?>
<web-appversion="2.5"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath*:/cxf-servlet.xml</param-value>
</context-param>
<listener>
<listener-class>
org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>
<servlet>
<servlet-name>CXFServlet</servlet-name>
<servlet-class>org.apache.cxf.transport.servlet.CXFServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>CXFServlet</servlet-name>
<url-pattern>/services/*</url-pattern>
</servlet-mapping>
</web-app>

cxf-servlet.xml
<?xmlversion="1.0"encoding="UTF-8"?>
<beansxmlns="http://www.springframework.org/schema/beans"
xmlns:cxf="http://cxf.apache.org/core"
xmlns:jaxws="http://cxf.apache.org/jaxws"
xmlns:http-conf="http://cxf.apache.org/transports/http/configuration"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://www.springframework.org/schema/beanshttp://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://cxf.apache.org/jaxwshttp://cxf.apache.org/schemas/jaxws.xsd
http://cxf.apache.org/corehttp://cxf.apache.org/schemas/core.xsd
http://cxf.apache.org/transports/http/configurationhttp://cxf.apache.org/schemas/configuration/http-conf.xsd">
<importresource="classpath:META-INF/cxf/cxf.xml"/>
<importresource="classpath:META-INF/cxf/cxf-servlet.xml"/>
<importresource="classpath:META-INF/cxf/cxf-extension-soap.xml"/>
<importresource="classpath:/cxf-in.xml"/>
<cxf:bus>
<cxf:inInterceptors>
<beanclass="cxfserver.WsdSoapInInterceptor"/>
</cxf:inInterceptors>
</cxf:bus>
<cxf:bus>
<cxf:inInterceptors>
<beanclass="zkg.SoapInInterceptor"/>
</cxf:inInterceptors>
</cxf:bus>
<beanid="hello"class="cxfserver.HelloWorldImpl"/>
<jaxws:endpointid="helloWorld"implementor="#hello"address="/HelloWorld">
<jaxws:inInterceptors>
<!--<beanclass="cxfserver.WsdSoapInInterceptor"></bean>
<beanclass="zkg.SoapInInterceptor"/>-->
</jaxws:inInterceptors>
</jaxws:endpoint>
</beans>

Copyright © Linux教程網 All Rights Reserved