`
ct_xiao0310
  • 浏览: 24494 次
  • 性别: Icon_minigender_1
  • 来自: 江西
社区版块
存档分类
最新评论

CXFServiceDemo

 
阅读更多

 

@WebService

public interface ICxfService {

@WebMethod

String syncAcc(@WebParam(name = "requestXml") String requestXml);

}

 

@WebService(endpointInterface = "com.venus.cxf.service.ICxfService", serviceName = "CxfService")

public class CxfServiceImpl implements ICxfService {

 

@Override

public String syncAcc(String requestXml) {

// TODO Auto-generated method stub

return "Request syncAcc successful! requestXml:" + requestXml;

}

}

 

spring-cxf.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" xmlns:jaxws="http://cxf.apache.org/jaxws"

xsi:schemaLocation="  

        http://www.springframework.org/schema/beans   

        http://www.springframework.org/schema/beans/spring-beans-3.0.xsd  

        http://cxf.apache.org/jaxws  

        http://cxf.apache.org/schemas/jaxws.xsd">

 

<!-- Import apache CXF bean definition 固定 -->

<import resource="classpath:META-INF/cxf/cxf.xml" />

<import resource="classpath:META-INF/cxf/cxf-extension-soap.xml" />

<import resource="classpath:META-INF/cxf/cxf-servlet.xml" />

 

<!-- services接口配置 -->

<bean id="cxfServicesBean" class="com.venus.cxf.service.impl.CxfServiceImpl" />

<!-- CXF 配置WebServices的服务名及访问地址 -->

<jaxws:server id="cxfServices" address="/CxfServices"

serviceClass="com.venus.cxf.service.ICxfService">

<!-- 要暴露的webservice服务 -->

<jaxws:serviceBean>

<ref bean="cxfServicesBean" />

</jaxws:serviceBean>

</jaxws:server>

</beans>

 

web.xml

 

<?xml version="1.0" encoding="UTF-8"?>

<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"

xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"

id="WebApp_ID" version="3.0">

 

<!-- Spring 容器加载的配置文件 设置 -->

<context-param>

<param-name>contextConfigLocation</param-name>

<param-value>

classpath:/spring-cxf.xml

</param-value>

</context-param>

 

<!-- Spring 配置 -->

<listener>

<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>

</listener>

<listener>

<listener-class>org.springframework.web.util.IntrospectorCleanupListener</listener-class>

</listener>

 

<!-- WebServices设置 -->

<servlet>

<servlet-name>CXFServices</servlet-name>

<servlet-class>org.apache.cxf.transport.servlet.CXFServlet</servlet-class>

<load-on-startup>0</load-on-startup>

</servlet>

<servlet-mapping>

<servlet-name>CXFServices</servlet-name>

<url-pattern>/services/*</url-pattern>

</servlet-mapping>

 

<welcome-file-list>

<welcome-file>index.jsp</welcome-file>

</welcome-file-list>

</web-app>  

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics