当前位置:文档之家› 通过CXF开发webService接口(soap协议、maven项目)

通过CXF开发webService接口(soap协议、maven项目)

1. 引入cxf的jar包

pom文件里面直接增加依赖

< dependency>

junit

junit

4.11

test

org.springframework

spring- webmvc

4.0.0.RELEASE

org.apache.cxf

apache-cxf

2.4.3

pom

2. 配置web.xml文件

< web-app xmlns= "/xml/ns/javaee"

xmlns:xsi= "/2001/XMLSchema-instance" xsi:schemaLocation=

"/xml/ns/javaee

/xml/ns/javaee/web-app_3_1.xsd" version= "3.1" >

< display-name >Archetype Created Web Application

< context-param >

contextConfigLocation

classpath:config/spring/metadata WebService-spring.xml

org.springframework.web.conte xt.ContextLoaderListener

CXFServlet

org.apache.cxf.transport.servl et.CXFServlet

CXFServlet

/services/*

encodingFilter

< filter-class>

org.springframework.web.filter.CharacterEncodingFilter

encoding

UTF-8

forceEncoding

true

encodingFilter

/*

3. 配置cxf.xml文件

< beans xmlns=

"/schema/beans"

xmlns:xsi=

"/2001/XMLSchema-instance" xmlns:jaxws= "/jaxws"

xmlns:context=

"/schema/context"

xmlns:jaxrs= "/jaxrs"

xsi:schemaLocation=

"/schema/beans

/schema/beans/sprin

g-beans.xsd

/jaxws

/schemas/jaxws.xsd

/schema/context

/schema/context/spr ing-context.xsd

/jaxrs

/schemas/jaxrs.xsd" >

"classpath:META-INF/cxf/cxf-servlet.xml" />

"org.apache.cxf.ws.security.wss4j.WSS4JInInterceptor" >

"org.apache.cxf.jaxws.JaxWsServerFactoryBean"

scope= "prototype" >

相关主题