一、简单的(结合Spring)

1、  新建一个web 项目,加入cfx所需要jar

2、  编写要发布的Web Service接口和实现类所需要jar

接口类 HelloWorld :

 import javax.jws.WebService;
@WebService
public interface HelloWorld
{
public String sayHello(String text);
}
实现类HelloWorldImpl :
import javax.jws.WebService;
@WebService(endpointInterface="hello.HelloWorld")
public class HelloWorldImpl implements HelloWorld
{
@Override
public String sayHello(String text){
return "Hello, " + text;
}
}

实现类HelloWorldImpl :

 import javax.jws.WebService;
@WebService(endpointInterface="hello.HelloWorld")
public class HelloWorldImpl implements HelloWorld
{
@Override
public String sayHello(String text){
return "Hello, " + text;
}
}

@WebService 注解表示是要发布的web 服务

3、  在applicationContext_cfx.xml配置要发布的Web Service

 <?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">
<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" />
<bean id="hello" class="hello.HelloWorldImpl" />
<jaxws:endpoint id="helloWorld" implementor=" hello.HelloWorldImpl "
address="/HelloWorld" />
</beans>

注意:<jaxws:endpoint id="helloWorld" implementor="#hello"           address="/HelloWorld" />   id:指在spring配置的bean的ID. Implementor:指明具体的实现类.  Address:指明这个web service的相对地址

4、 配置web.xml文件

 <context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath*: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>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>CXFServlet</servlet-name>
<url-pattern>/services/*</url-pattern>
</servlet-mapping>

5、 部署到tomcat服务器,输入:http://localhost:8080/<web-app-name>/ HelloWorld?wsdl,将显示这个web service的wsdl.

注意:如果web.xml配置<servlet-name>CXFServlet</servlet-name>           <url-pattern>/ws/*</url-pattern>   则访问地址为:http://localhost:8080/<web-app-name>/ws/ HelloWorld?wsdl

基于cfx的webservice调用的更多相关文章

  1. python发布及调用基于SOAP的webservice

    现如今面向服务(SOA)的架构设计已经成为主流,把公用的服务打包成一个个webservice供各方调用是一种非常常用的做法,而应用最广泛的则是基于SOAP协议和wsdl的webservice.本文讲解 ...

  2. 添加webservice调用日志

    之前想用spring的AOP给webservice添加切面的,但是使用around切面后,居然调用端得不到webservice的返回结果,而且报文的详细情况也不得而知,很是尴尬,所以偷了个懒.但是该做 ...

  3. 基于.NET的WebService的实现和WCF的实现

    1.新建一个MVC web项目. 2.点击项目,[右键]→[添加]→[新建项] 3.点击[Web]→[Web服务] 4.恭喜,Web Service已经新建成功,里面的方法就可以参考着根据自己的需要进 ...

  4. 基于Jws的WebService项目

    基于Jws的WebService项目   1.服务器端建立 1.1.创建接口 [java] view plaincopy @WebService  public interface IWebServi ...

  5. webservice调用和生成

    webservice简介: Web Service技术, 能使得运行在不同机器上的不同应用无须借助附加的.专门的第三方软件或硬件, 就可相互交换数据或集成.依据Web Service规范实施的应用之间 ...

  6. 纯 Java 开发 WebService 调用测试工具(wsCaller.jar)

    注:本文来自hacpai.com:Tanken的<纯 Java 开发 WebService 调用测试工具(wsCaller.jar)>的文章 基于 Java 开发的 WebService ...

  7. springboot+cfx实现webservice功能

    一.开发服务端 1.新建工程 cfx-webservice ,最终的完整工程如下: pom.xml如下: <?xml version="1.0" encoding=" ...

  8. Myeclipse8.5上基于JAX-WS开发WebService

    1.JAX-WS介绍 JAX-WS规范是一组XML web services的JAVA API. 2.开发步骤 基于JAX-WS的WebService开发步骤如下: 2.1 新建一个Web Servi ...

  9. 使用sproxy.exe访问基于soap的webservice

    使用vc访问基于soap的webservice有多种方法,其中有一种是使用atlsoap,关于这个可以搜索sproxy.exe文章,不在这介绍(主要是我的写作能力太差).我写这个日记主要是项记录访问w ...

随机推荐

  1. mvcAPI (入门 1)

    步骤: 1)建立order 类 2)建立OrderEntity类 3)创建控制器API 这时候能看到Json 格式的数据啦 5)想在网页或客户端显示 添加一个网页 如下: <!DOCTYPE h ...

  2. 通过两根RS232连接两台电脑

    把RS232的有5脚那边放下面,最左边是GND,第二三是TXD和RXD,两个RS232反接,然后两个usb连接电脑就可以通信了

  3. Linux 上网络监控工具 ntopng 的安装

    当今世界,人们的计算机都相互连接,互联互通.小到你的家庭局域网(LAN),大到最大的一个被我们称为互联网.当你管理一台联网的计算机时,你就是在管理最关键的组件之一.由于大多数开发出的应用程序都基于网络 ...

  4. Cheatsheet: 2014 09.01 ~ 09.30

    Mobile Testing Mobile: Emulators, Simulators And Remote Debugging iOS 8 and iPhone 6 for Web Develop ...

  5. ubuntu下读取数据库中文乱码解决

    请按如下配置myqsl.cnf (/etc/mysql/mysql.conf.d/mysql.cnf ),然后重启mysql服务,对于web程序,你可以把web所有编码都搞成utf-8[client] ...

  6. Run_Product Example Form - Oracle Forms 6i

    I have already posted in my previous post Running Reports Using Run_Product to run reports in Oracle ...

  7. Codeforces Round #260 (Div. 2)AB

    http://codeforces.com/contest/456/problem/A A. Laptops time limit per test 1 second memory limit per ...

  8. python_way day18 html-day4, Django路由,(正则匹配页码,包含自开发分页功能), 模板, Model(jDango-ORM) : SQLite,数据库时间字段插入的方法

    python_way day18 html-day4 1.Django-路由系统   - 自开发分页功能 2.模板语言:之母板的使用 3.SQLite:model(jDango-ORM) 数据库时间字 ...

  9. iOS - Swift iOS 开发体系

    1.iOS 开发技术体系 iOS 开发技术体系图: 层级 主要框架 Cocoa Touch UIKit 等 Media Core Graphics .OpenGl ES.Core Animation ...

  10. 手动导出Excel方法

    private void dgJiBingZhenDuanBind() {   Response.Clear(); Response.Charset = "GB2312"; Res ...