基于cfx的webservice调用
一、简单的(结合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调用的更多相关文章
- python发布及调用基于SOAP的webservice
现如今面向服务(SOA)的架构设计已经成为主流,把公用的服务打包成一个个webservice供各方调用是一种非常常用的做法,而应用最广泛的则是基于SOAP协议和wsdl的webservice.本文讲解 ...
- 添加webservice调用日志
之前想用spring的AOP给webservice添加切面的,但是使用around切面后,居然调用端得不到webservice的返回结果,而且报文的详细情况也不得而知,很是尴尬,所以偷了个懒.但是该做 ...
- 基于.NET的WebService的实现和WCF的实现
1.新建一个MVC web项目. 2.点击项目,[右键]→[添加]→[新建项] 3.点击[Web]→[Web服务] 4.恭喜,Web Service已经新建成功,里面的方法就可以参考着根据自己的需要进 ...
- 基于Jws的WebService项目
基于Jws的WebService项目 1.服务器端建立 1.1.创建接口 [java] view plaincopy @WebService public interface IWebServi ...
- webservice调用和生成
webservice简介: Web Service技术, 能使得运行在不同机器上的不同应用无须借助附加的.专门的第三方软件或硬件, 就可相互交换数据或集成.依据Web Service规范实施的应用之间 ...
- 纯 Java 开发 WebService 调用测试工具(wsCaller.jar)
注:本文来自hacpai.com:Tanken的<纯 Java 开发 WebService 调用测试工具(wsCaller.jar)>的文章 基于 Java 开发的 WebService ...
- springboot+cfx实现webservice功能
一.开发服务端 1.新建工程 cfx-webservice ,最终的完整工程如下: pom.xml如下: <?xml version="1.0" encoding=" ...
- Myeclipse8.5上基于JAX-WS开发WebService
1.JAX-WS介绍 JAX-WS规范是一组XML web services的JAVA API. 2.开发步骤 基于JAX-WS的WebService开发步骤如下: 2.1 新建一个Web Servi ...
- 使用sproxy.exe访问基于soap的webservice
使用vc访问基于soap的webservice有多种方法,其中有一种是使用atlsoap,关于这个可以搜索sproxy.exe文章,不在这介绍(主要是我的写作能力太差).我写这个日记主要是项记录访问w ...
随机推荐
- unicode下char*和CString和一些数据之间的转换
首先mfc下字符串只有两种数据:char(一个字节)和wchar_t(两个字节),很多其他数据类型如TCHAR,WCHAR等都是这个两个基本类型的宏定义,BYTE是uchar 1.对话框打印char* ...
- iptraf:TCP/UDP网络监控工具
原文:http://www.unixmen.com/iptraf-tcpudp-network-monitoring-utility/ 作者: Enock Seth Nyamador 译文:LCTT ...
- WINCE6.0组件选择说明
WINCE6.0组件选择说明 图1 RAS/PPP组件前面的√标识表示我们手动选择,TAPI2.0前面的■标识表示选组件时根据依赖关系自动选择的,PPPoE前面的□标识组件没有选择.
- 未能加载文件或程序集“CefSharp, Version=1.25.XXXX”或它的某一个依赖项。试图加载格式不正确的程序。
在使用CefSharp的过程中遇到一个坑爹的错误. 从GitHub的项目主页:https://github.com/cefsharp/CefSharp/wiki/Frequently-asked-qu ...
- Response.Cookies 和 Request.Cookies
Response.Cookies 和 Request.Cookies 原文地址: http://www.cnblogs.com/forcertain/archive/2012/12/04/28 ...
- matplotlib
前导: 安装 numpy http://sourceforge.net/projects/numpy/files/ http://sourceforge.net/projects/numpy/file ...
- 高效的使用STL
高效的使用STL 仅仅是个选择的问题,都是STL,可能写出来的效率相差几倍: 熟悉以下条款,高效的使用STL: 当对象很大时,建立指针的容器而不是对象的容器 1)STL基于拷贝的方式的来工作,任何需要 ...
- Perfection Kills
<!doctype html> <html> <head> <meta charset="utf-8"> <title> ...
- [转]linux中如何安装软件?
Linux下软件的安装与卸载 在Windows下安装软件时,只需运行软件的安装程序(setup.install等)或者用zip等解压缩软件解开即可安装,运行反安装程序 (uninstall.u ...
- Android 使用finalBitmap实现缓存读取
public class NewsApplication extends Application{ private FinalBitmap finalBitmap=null; public Final ...