1、建工程,导入CXFjar包

2、服务接口

package com.cxf.soap;

import java.util.List;
import javax.jws.WebService; @WebService
public interface PeopleService { public String add(People people); public String del(People people); public String modify(People people); public People getOne(Long id); public List<People> getList(People people);
}

3、服务接口实现类

package com.cxf.soap;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import javax.jws.WebService; @WebService(endpointInterface="com.cxf.soap.PeopleService")
public class PeopleServiceImpl implements PeopleService { @Override
public String add(People people) {
// TODO Auto-generated method stub
System.out.println("ADD:"+people.getId()+","+people.getName()+","+people.getBirthday());
return "ADD SUCCESS";
} @Override
public String del(People people) {
// TODO Auto-generated method stub
System.out.println("DEL:"+people.getId()+","+people.getName());
return "DEL SUCCESS";
} @Override
public String modify(People people) {
// TODO Auto-generated method stub
System.out.println("MODIFY:"+people.getId()+","+people.getName());
return "MODIFY SUCCESS";
} @Override
public People getOne(Long id){
// TODO Auto-generated method stubSystem.out.println("QRY BEGIN");
People people=new People();
people.setId(4L);
people.setName("Name-004");
people.setBirthday(new Date());
return people; }
@Override
public List<People> getList(People p){
// TODO Auto-generated method stub
List<People> list=new ArrayList<People>();
People people0=new People();
People people1=new People();
people0.setId(5L);
people0.setName(p.getName()+"-005");
people0.setBirthday(new Date());
people1.setId(6L);
people1.setName(p.getName()+"-006");
people1.setBirthday(new Date());
list.add(people0);
list.add(people1);
return list;
}
}

4、参数类

package com.cxf.soap;

import java.util.Date;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement; @XmlAccessorType(XmlAccessType.FIELD)
@XmlRootElement(name = "People")
public class People {
private Long id;
private String name;
private Date birthday; public Long getId() {
return id;
} public void setId(Long id) {
this.id = id;
} public String getName() {
return name;
} public void setName(String name) {
this.name = name;
} public Date getBirthday() {
return birthday;
} public void setBirthday(Date birthday) {
this.birthday = birthday;
}
}

5、配置映射Service , beans.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.xsd http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd"> <!-- 接口名称、访问路径、实现类 -->
<jaxws:endpoint id="peopleService" address="/peopleService" implementor="com.cxf.soap.PeopleServiceImpl"/>
</beans>

6、在Spring配置文件中加载映射,applicationContext.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"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">
<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" />
<import resource="classpath:beans.xml" />
<!-- <import resource="classpath:rest-services.xml" /> -->
</beans>

7、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">
<display-name>SpringCXFService</display-name> <context-param>
<param-name>contextConfigLocation</param-name>
<param-value>WEB-INF/classes/applicationContext.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>/*</url-pattern>
</servlet-mapping> <welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
</web-app>

8、访问测试

http://127.0.0.1:8080/SpringCXFService/peopleService?wsdl

This XML file does not appear to have any style information associated with it. The document tree is shown below.
<wsdl:definitions xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:tns="http://soap.cxf.com/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:ns1="http://schemas.xmlsoap.org/soap/http" name="PeopleServiceImplService" targetNamespace="http://soap.cxf.com/">
<wsdl:types>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://soap.cxf.com/" elementFormDefault="unqualified" targetNamespace="http://soap.cxf.com/" version="1.0">
<xs:element name="People" type="tns:people"/>
<xs:element name="add" type="tns:add"/>
<xs:element name="addResponse" type="tns:addResponse"/>
<xs:element name="del" type="tns:del"/>
<xs:element name="delResponse" type="tns:delResponse"/>
<xs:element name="getList" type="tns:getList"/>
<xs:element name="getListResponse" type="tns:getListResponse"/>
<xs:element name="getOne" type="tns:getOne"/>
<xs:element name="getOneResponse" type="tns:getOneResponse"/>
<xs:element name="modify" type="tns:modify"/>
<xs:element name="modifyResponse" type="tns:modifyResponse"/>
<xs:complexType name="del">
<xs:sequence>
<xs:element minOccurs="0" name="arg0" type="tns:people"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="people">
<xs:sequence>
<xs:element minOccurs="0" name="id" type="xs:long"/>
<xs:element minOccurs="0" name="name" type="xs:string"/>
<xs:element minOccurs="0" name="birthday" type="xs:dateTime"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="delResponse">
<xs:sequence>
<xs:element minOccurs="0" name="return" type="xs:string"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="getList">
<xs:sequence>
<xs:element minOccurs="0" name="arg0" type="tns:people"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="getListResponse">
<xs:sequence>
<xs:element maxOccurs="unbounded" minOccurs="0" name="return" type="tns:people"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="add">
<xs:sequence>
<xs:element minOccurs="0" name="arg0" type="tns:people"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="addResponse">
<xs:sequence>
<xs:element minOccurs="0" name="return" type="xs:string"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="getOne">
<xs:sequence>
<xs:element minOccurs="0" name="arg0" type="xs:long"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="getOneResponse">
<xs:sequence>
<xs:element minOccurs="0" name="return" type="tns:people"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="modify">
<xs:sequence>
<xs:element minOccurs="0" name="arg0" type="tns:people"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="modifyResponse">
<xs:sequence>
<xs:element minOccurs="0" name="return" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:schema>
</wsdl:types>
<wsdl:message name="getOneResponse">
<wsdl:part element="tns:getOneResponse" name="parameters"></wsdl:part>
</wsdl:message>
<wsdl:message name="addResponse">
<wsdl:part element="tns:addResponse" name="parameters"></wsdl:part>
</wsdl:message>
<wsdl:message name="delResponse">
<wsdl:part element="tns:delResponse" name="parameters"></wsdl:part>
</wsdl:message>
<wsdl:message name="add">
<wsdl:part element="tns:add" name="parameters"></wsdl:part>
</wsdl:message>
<wsdl:message name="getOne">
<wsdl:part element="tns:getOne" name="parameters"></wsdl:part>
</wsdl:message>
<wsdl:message name="del">
<wsdl:part element="tns:del" name="parameters"></wsdl:part>
</wsdl:message>
<wsdl:message name="modify">
<wsdl:part element="tns:modify" name="parameters"></wsdl:part>
</wsdl:message>
<wsdl:message name="modifyResponse">
<wsdl:part element="tns:modifyResponse" name="parameters"></wsdl:part>
</wsdl:message>
<wsdl:message name="getListResponse">
<wsdl:part element="tns:getListResponse" name="parameters"></wsdl:part>
</wsdl:message>
<wsdl:message name="getList">
<wsdl:part element="tns:getList" name="parameters"></wsdl:part>
</wsdl:message>
<wsdl:portType name="PeopleService">
<wsdl:operation name="del">
<wsdl:input message="tns:del" name="del"></wsdl:input>
<wsdl:output message="tns:delResponse" name="delResponse"></wsdl:output>
</wsdl:operation>
<wsdl:operation name="getList">
<wsdl:input message="tns:getList" name="getList"></wsdl:input>
<wsdl:output message="tns:getListResponse" name="getListResponse"></wsdl:output>
</wsdl:operation>
<wsdl:operation name="add">
<wsdl:input message="tns:add" name="add"></wsdl:input>
<wsdl:output message="tns:addResponse" name="addResponse"></wsdl:output>
</wsdl:operation>
<wsdl:operation name="getOne">
<wsdl:input message="tns:getOne" name="getOne"></wsdl:input>
<wsdl:output message="tns:getOneResponse" name="getOneResponse"></wsdl:output>
</wsdl:operation>
<wsdl:operation name="modify">
<wsdl:input message="tns:modify" name="modify"></wsdl:input>
<wsdl:output message="tns:modifyResponse" name="modifyResponse"></wsdl:output>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="PeopleServiceImplServiceSoapBinding" type="tns:PeopleService">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="del">
<soap:operation soapAction="" style="document"/>
<wsdl:input name="del">
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output name="delResponse">
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="add">
<soap:operation soapAction="" style="document"/>
<wsdl:input name="add">
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output name="addResponse">
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="getList">
<soap:operation soapAction="" style="document"/>
<wsdl:input name="getList">
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output name="getListResponse">
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="getOne">
<soap:operation soapAction="" style="document"/>
<wsdl:input name="getOne">
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output name="getOneResponse">
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="modify">
<soap:operation soapAction="" style="document"/>
<wsdl:input name="modify">
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output name="modifyResponse">
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="PeopleServiceImplService">
<wsdl:port binding="tns:PeopleServiceImplServiceSoapBinding" name="PeopleServiceImplPort">
<soap:address location="http://192.168.1.7:8080/SpringCXFService/peopleService"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>

CXF、Spring整合的SOAP Web Service服务端的更多相关文章

  1. 基于JAX-WS的Web Service服务端/客户端 ;JAX-WS + Spring 开发webservice

    一.基于JAX-WS的Web Service服务端/客户端 下面描述的是在main函数中使用JAX-WS的Web Service的方法,不是在web工程里访问,在web工程里访问,参加第二节. JAX ...

  2. Linux下用gSOAP开发Web Service服务端和客户端程序

    网上本有一篇流传甚广的C版本的,我参考来实现,发现有不少问题,现在根据自己的开发经验将其修改,使用无误:另外,补充同样功能的C++版本,我想这个应该更有用,因为能用C++,当然好过受限于C. 1.gS ...

  3. 使用axis开发web service服务端

    一.axis环境搭建 1.安装环境 JDK.Tomcat或Resin.eclipse等. 2.到 http://www.apache.org/dyn/closer.cgi/ws/axis/1_4下载A ...

  4. 使用Eclipse自带Web Service插件(Axis1.4)生成Web Service服务端/客户端

    创建一个名字为math的Java web工程,并将WSDL文件拷入该工程中 将Axis所需的jar包拷贝至WebRoot\WEB-INF\lib目录下,这些jar包会自动导入math工程中 一,生成W ...

  5. Eclipse+Axis使用WSDL文件生成Web Service服务端/客户端

    JDK版本:1.5.0_22 Eclipse版本:Helios Service Release 2(3.6.2) WSDL文件的创建过程见http://blog.csdn.net/a19881029/ ...

  6. 使用Eclipse自带的Axis1插件生成Web Service服务端客户端

    JDK版本:1.5.0_22 Eclipse版本:Helios Service Release 2(3.6.2) WSDL文件的创建过程见http://blog.csdn.net/a19881029/ ...

  7. ubuntu下安装 gSOAP 用于C/C++开发web service服务端与客户端

    昨天在ubuntu下进行安装gSOAP,费了很多时间,没成功,今天又来找了大量教程资料,终于一次成功,这里写下自己的安装步骤和方法,供大家参考. 首先下载gsoap,我下载的是gsoap-2.8.1. ...

  8. 翻译-使用Spring WebService生成SOAP Web Service

    原文链接:http://spring.io/guides/gs/producing-web-service/ 生成SOAP web service 该指南将带领你使用Spring创建一个基于SOAP的 ...

  9. 基于Apache CXF的Web Service服务端/客户端

    转自:https://www.aliyun.com/zixun/wenji/1263190.html CXF服务端: package com.sean.server; import javax.jws ...

随机推荐

  1. tensorflow 如何限制显存大小

    Python在用GPU跑模型的时候最好开多进程,因为很明显这种任务就是计算密集型的. 用进程池好管理,但是tensorflow默认情况会最大占用显存,尽管该任务并不需要这么多,因此我们可以设置显存的按 ...

  2. c++ string char* 获取输入值的区别

    #include <iostream> #include <string> using namespace std; void reverseStr(string &s ...

  3. ospf 提升 二 ---LSA

    ospf ABR和ASBR的区别 官方建议中大型网络的规模参考   根据spf算法   而不是路由器的硬件性能强弱 a ABR最多关联3个区域 b 单区域内路由器最多50台 c 一台运行ospf的路由 ...

  4. 九度oj 题目1130:日志排序

    题目描述: 有一个网络日志,记录了网络中计算任务的执行情况,每个计算任务对应一条如下形式的日志记录:“hs_10000_p”是计算任务的名称,“2007-01-17 19:22:53,315”是计算任 ...

  5. 九度oj 题目1099:后缀子串排序

    题目描述: 对于一个字符串,将其后缀子串进行排序,例如grain其子串有:grain rain ain in n 然后对各子串按字典顺序排序,即: ain,grain,in,n,rain 输入: 每个 ...

  6. 【Luogu】P1352没有上司的舞会(树形DP)

    题目链接 设f[i][0]表示第i个人不去舞会时子树的最大欢乐度,f[i][1]表示第i个人去舞会时子树的最大欢乐度. 则有状态转移方程:f[i][0]+=∑max(f[to][0],f[to][1] ...

  7. java 数据库连接的几个步骤

    Class.forName("oracle.jdbc.driver.OracleDriver"); String url = "jdbc:oracle:thin:@你的主 ...

  8. 文艺平衡树(bzoj 3223)

    Description   您需要写一种数据结构(可参考题目标题),来维护一个有序数列,其中需要提供以下操作:翻转一个区间,例如原有序序列是5 4 3 2 1,翻转区间是[2,4]的话,结果是5 2  ...

  9. .net面试题汇总一第一篇

    1. 简述 private. protected. public. internal 修饰符的访问权限. private:私有成员,只能在类内部中才可以访问. protected:受保护的,只能在该类 ...

  10. Educational Codeforces Round 51 (Rated for Div. 2) The Shortest Statement

    题目链接:The Shortest Statement 今天又在群里看到一个同学问$n$个$n$条边,怎么查询两点直接最短路.看来这种题还挺常见的. 为什么最终答案要从42个点的最短路(到$x,y$) ...