基于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 ...
随机推荐
- Springmvc整合tiles框架简单入门示例(maven)
Springmvc整合tiles框架简单入门示例(maven) 本教程基于Springmvc,spring mvc和maven怎么弄就不具体说了,这边就只简单说tiles框架的整合. 先贴上源码(免积 ...
- 如何提高android串口kernel log等级
在 /device/qcom/common/rootdir/etc/init.qcom.rc write /proc/sys/kernel/printk "6 6 1 7" 第一 ...
- 【leetcode❤python】 36. Valid Sudoku
#-*- coding: UTF-8 -*-#特定的九个格内1-9的个数至多为1#依次检查每行,每列,每个子九宫格是否出现重复元素,如果出现返回false,否则返回true.class Solutio ...
- Create,Insert
创建表 create table people ( id int ,name ) ) create table toys ( id int ,name ) ,people_id int ) CREAT ...
- Date Picker Calendar For Oracle Forms 6i
Giving date picker calendar option to user for date type fields in Oracle Forms. I am providing you ...
- Oracle的数据恢复——Flashback用法汇总
/* 11g的flashbackup 分好几种,分别用途不一样. A.flashback database 闪回数据库,简单理解就是把数据库闪回到某个以前的时间点, 能恢复到的最早的SCN, 取决与F ...
- Java自制人机小游戏——————————剪刀、石头、布
package com.hello.test; import java.util.Scanner; public class TestGame { public static void main(St ...
- 04_IOC容器装配Bean(xml方式)
IOC容器装配Bean(xml方式) 1.Spring 提供配置Bean三种实例化方式 1)使用类构造器实例化(默认无参数) <bean id="bean1" class=& ...
- ABAP RFC远程调用
声明:原创作品,转载时请注明文章来自SAP师太技术博客( 博/客/园www.cnblogs.com):www.cnblogs.com/jiangzhengjun,并以超链接形式标明文章原始出处,否则将 ...
- CI实践_Android持续集成
之前已经实现了Android的持续集成,并在项目中应用了一段时间.恰逢现在有几分钟时间,把之前的一些零散的点滴记录和整理一下,供有需要的朋友参考,或后续复用. 需要的准备知识:gitlab.Jenki ...