《通过CXF开发webService接口(soap协议maven项目)》由会员分享,可在线阅读,更多相关《通过CXF开发webService接口(soap协议maven项目)(5页珍藏版)》请在人人文库网上搜索。
1、1. 引入cxf的jar包pom文件里面直接增加依赖junitjunit4.11 test org.springframework spring- webmvc4.0.0.RELEASEorg.apache.cxf apache-cxf 2.4.3pom2. 配置web.xml文件Archetype Created Web Application contextConfigLocation classpath:config/spring/metadataWebService-spring.xml org.springframework.web.context.ContextLoaderList。
2、ener CXFServlet org.apache.cxf.transport.servlet.CXFServlet CXFServlet /services/* encodingFilter org.springframework.web.filter.CharacterEncodingFilter encoding UTF-8 forceEncoding true encodingFilter /* 3. 配置cxf.xml文件4. 要开放的接口加上cxf服务的注解接口类:WebService (portName = inbound.webServices.ticket.saServic。
3、eSoap12 )javax.xml.ws.soap. MTOMpublic interface DemoService WebMethodpublic String demo( WebParam(name = demo) Demo demo);接口实现类:ComponentWebService (portName = inbound.webServices.ticket.saServiceSoap12 )BindingType (value = http:/www.w3.org/2003/05/soap/bindings/HTTP/ )public class DemoServiceImpl。
4、 implements DemoService publicString Demo(Demo demo) String userName = demo.getUserName();Stringpassword= demo.getPassword();return success;Demo实体类:publicClass Demo() public String userName;public String password;public StringgetUserName() returnuserName;public void setUserName(StringuserName) this.userName=userName;public StringgetPassword() returnpassword;public void setPassword(Stringpassword) this.password=password;5. 部署到tomcat启动即可,测试访问 ip:端口号/项目名称/services。