搭建web项目结合spring+cxf的webservice服务
2014-06-24 16:05
549 查看
[b]服务端:[/b]
服务端和客户端都需要引入包
View Code
然后
localhost:8080/项目地址/hi?xsdl
[b]客户端[/b]
利用 wsimport -s 地址 或者ws2java -s地址的命令
得到文件后
把接口文件复制来
配置文件 ClientBean.xml
测试 IHiService就是拷贝过来的接口文件,放到项目中
服务端和客户端都需要引入包
package cn.itcast.cxf; public class HiServiceImpl implements IHiService { @Override public String sayHi(String name) { System.out.println("sayHi...."); return "hi " + name; } }
View Code
然后
localhost:8080/项目地址/hi?xsdl
[b]客户端[/b]
利用 wsimport -s 地址 或者ws2java -s地址的命令
得到文件后
把接口文件复制来
配置文件 ClientBean.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" xmlns:soap="http://cxf.apache.org/bindings/soap" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://cxf.apache.org/bindings/soap http://cxf.apache.org/schemas/configuration/soap.xsd http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd"> <!-- 配置客户端bean --> <!-- id:唯一标识 address:请求的服务地址 serviceClass:客户端接口 --> <jaxws:client id="hiService" address="http://localhost/CXF_03/cxf/hi" serviceClass="cn.itcast.cxf.IHiService"></jaxws:client> </beans>
测试 IHiService就是拷贝过来的接口文件,放到项目中
package cn.itcast.test; import org.springframework.context.ApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; import cn.itcast.cxf.IHiService; public class Test1 { public static void main(String[] args) { //初始化spring ApplicationContext ctx = new ClassPathXmlApplicationContext("ClientBeans.xml"); IHiService s = (IHiService) ctx.getBean("hiService"); s.sayHi("abc"); System.out.println(s.getClass().getName()); } }
相关文章推荐
- 搭建web项目结合spring+cxf的webservice服务
- 搭建web项目结合spring+cxf的webservice服务
- 搭建web项目结合spring+cxf的webservice服务
- Spring 集成CXF框架发布Webservice服务 和 使用jdk生成Webservice clinet
- 在web项目中使用cxf开发webservice,包含spring支持
- 【Spring_WebService(CXF)】环境的搭建以及服务的暴露
- CXF3.0.1+spring+maven搭建webservice服务
- 【webservice】CXF结合spring发布简单的webservice服务
- CXF3.0.4与spring整合开发Webservice功能的web项目
- Spring Boot(二):快速搭建web项目或微服务
- webservice之cxf实现[web项目中基于maven与spring整合]
- Spring Cloud搭建微服务架构----使用Spring boot开发web项目
- cxf3.0.4结合spring搭建webservice服务端的框架必需的最少jar包
- webservice--cxf和spring结合,发布restFull风格的服务
- 使用cxf框架搭建基于Spring远程调用Web服务
- 使用CXF和spring搭建webService服务
- WebService实战(二)——在Web项目中创建CXF服务
- 基于spring的调用web形式的cxf服务的方法
- WebService从零到项目开发使用3—技术研究之Axis2 POJO开发Web服务
- Spring与CXF结合发布WebService