一、简单的(结合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. 看懂UML类图和时序图

    看懂UML类图和时序图 这里不会将UML的各种元素都提到,我只想讲讲类图中各个类之间的关系: 能看懂类图中各个类之间的线条.箭头代表什么意思后,也就足够应对 日常的工作和交流: 同时,我们应该能将类图 ...

  2. 如何用linux远程登录windows计算机

    大家可能试过用windows远程登录另一个windows pc机,今天大家将会学到如何用 linux远程登录你的windows系统. 首先大家要做到得救是将自己linux和windows操作机的IP地 ...

  3. mysql中整数类型后面的数字,是不是指定这个字段的长度?比如int(11),11代表11个字节吗?

    原文地址:    http://www.cnblogs.com/stringzero/p/5707467.html 原先对mysql不太理解,但也没有报错.但理解的不够深入.这次补上. 原来以为int ...

  4. Mysql事件学习

    出自:http://blog.chinaunix.net/uid-20639775-id-3323098.html Mysql事件学习 在系统管理或者数据库管理中,经常要周期性的执行某一个命令或者SQ ...

  5. [CF738A]Interview with Oleg(模拟)

    题目链接:http://codeforces.com/contest/738/problem/A 题意:把ogo..ogo替换成***. 写的有点飘,还怕FST.不过还好 #include <b ...

  6. Servlet与Tomcat

    Web应用不仅局限于展示在服务器上的静态页面,更多的是根据用的请求动态的生成页面信息,还可以从数据库中提取数据,生成页面返回给用户. 第一种方法:遵循HTTP协议实现一个服务器端软件 第二种方法:利用 ...

  7. Tomcat源码导入Eclipse测试

    想要研究下Tomcat的体系结构或者源码,最好将Tomcat的源码导入到ide中,编写实例进行代码跟踪(debug). 这里参考了网上一些资料,将自己操作过程记个流水账. 准备: 1.Tomcat源码 ...

  8. [SAP ABAP开发技术总结]ALV

    声明:原创作品,转载时请注明文章来自SAP师太技术博客( 博/客/园www.cnblogs.com):www.cnblogs.com/jiangzhengjun,并以超链接形式标明文章原始出处,否则将 ...

  9. 没有Path的Binding

    当Binding源本身就是数据且不需要Path来指明时,可以设置Path的值为".",或直接省略Path.XAML中这个"."可以省略不写,但在C#代码中是不能 ...

  10. c++ IO的继承结构

    #include <stdio.h> #include <iostream>//cin,cout #include <sstream>//ss transfer. ...