博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
spring 集成 webservice 进过反复测试终于完成了
阅读量:7102 次
发布时间:2019-06-28

本文共 2080 字,大约阅读时间需要 6 分钟。

依赖jar,版本号3.1.6

org.apache.cxf
cxf-rt-frontend-jaxws
3.1.6
org.apache.cxf
cxf-rt-transports-http
${cxf.version}
org.apache.cxf
cxf-rt-bindings-soap
${cxf.version}
复制代码

编写webservice 接口

import javax.jws.WebService;

@WebService

public interface IDemoWebService {

public String sayHello(String text);复制代码

}

编写webservice实现类

import javax.jws.WebService;

import org.springframework.beans.factory.annotation.Autowired;

import com.xtt.platform.util.config.SpringUtil;

import com.xtt.txgl.patient.service.IMedicalOrderService;

@WebService(endpointInterface = "com.xtt.txgl.ws.IDemoWebService")

public class DemoWebServiceImpl implements IDemoWebService {

@Autowiredprivate IMedicalOrderService orderService;public String sayHello(String text) {    System.out.println(SpringUtil.getBean("patientAccountServiceImpl"));        System.out.println(orderService);        return "Hello : " + text;}复制代码

}


配置spring-webservice.xml

<beans xmlns="http://www.springframework.org/schema/beans"

xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

xmlns:p="http://www.springframework.org/schema/p"

xmlns:jaxws="http://cxf.apache.org/jaxws"

xmlns:cxf="http://cxf.apache.org/core"

xsi:schemaLocation="http://www.springframework.org/schema/beans

http://www.springframework.org/schema/beans/spring-beans-2.5.xsd

http://cxf.apache.org/jaxws

http://cxf.apache.org/schemas/jaxws.xsd">

复制代码

配置web.xml

contextConfigLocation
classpath*:config/springContext.xmlclasspath*:config/webservice.xml//引入webservice配置
复制代码

处理webservice请求

ws
org.apache.cxf.transport.servlet.CXFServlet
1
ws
/webservice/*
复制代码

访问方式:

http://localhost/cheetah/webservice/apiws?wsdl

转载于:https://juejin.im/post/5c806cb0e51d455c912fbd62

你可能感兴趣的文章
C# messagebox 居中父窗体
查看>>
阮一峰 ---开发者手册
查看>>
Java中的运算符和各种运算符的优先级和结合性及注意事项整理
查看>>
Exp5 MSF基础应用
查看>>
target/action设计模式
查看>>
bzoj1070【SCOI2007】修车(费用流)
查看>>
[bzoj 1086][SCOI2005]王室联邦
查看>>
设计模式学习笔记 1.介绍
查看>>
Java的Properties使用及格式定义
查看>>
树链剖分(转)
查看>>
SQL SERVER 数据类型 (转)
查看>>
linux工作常用命令
查看>>
博客系统 01 登录退出
查看>>
机试题
查看>>
客户端与服务器
查看>>
AtCoder Regular Contest 064 F - Rotated Palindromes
查看>>
cookie
查看>>
jquery改变元素的值的函数text(),html(),val()
查看>>
[深入JUnit] 测试运行的入口
查看>>
Vmware 虚拟机三种网络模式最详细解说【转载】
查看>>