Spring发布WebService并调用已有的WebService
发布WebService
1.编写生成WebService的Java类
package com.webService;
import com.service.PianoServiceImpl;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.FileSystemXmlApplicationContext;
import javax.jws.WebMethod;
import javax.jws.WebResult;
import javax.jws.WebService;
@WebService(name = "PianoService",serviceName = "PianoWebService")
public class PianoWebService {
@WebMethod(operationName = "getPrice",action = "getPriceByBrand")
@WebResult(name="price")
public int getPriceByBrand(String brand){
ApplicationContext ctx = new FileSystemXmlApplicationContext("src/applicationContext.xml");
PianoServiceImpl pianoService = (PianoServiceImpl) ctx.getBean("pianoServiceImpl");
return pianoService.getPriceByBrand(brand);
}
}
2.发布WebService
public static void main(String[] args) {
PianoWebService pianoWebService = new PianoWebService();
Endpoint.publish("http://localhost:8080/pianowebservice",pianoWebService);
System.out.println("启动webservice");
}
3.打开浏览器生成URL输入:http://localhost:8080/pianowebservice?wsdl即可浏览到WebService所产生的WSDL全文
调用已有的WebService
1.生成对应的Java文件
C:\Program Files\Java\jdk1.8.0_73\bin>wsimport -d F:\ -s F:\ -p com http://localhost:8080/pianowebservice?wsdl

2.把Java文件拷贝到项目中


3.调用
PianoWebService pianoWebService = new PianoWebService();
PianoService pianoService = pianoWebService.getPianoServicePort();
int price = pianoService.getPrice("IQOO");
System.out.println("获得价格:"+price);

附常用的WebService目录
http://www.webxml.com.cn/zh_cn/web_services.aspx
Spring发布WebService并调用已有的WebService的更多相关文章
- 调用已发布的WebService
WebService服务演示 登录http://www.webxml.com.cn
- CXF整合Spring发布WebService实例
一.说明: 上一篇简单介绍了CXF以及如何使用CXF来发布一个简单的WebService服务,并且介绍了客户端的调用. 这一篇介绍如何使用CXF与spring在Web项目中来发布WebService服 ...
- CXF2.7整合spring发布webservice
---------==========--服务端发布webservice-=============-------- 1.需要的jar包: 2.包结构 3.代码 1.实体类 package cn.ql ...
- 解决cxf+spring发布的webservice,types,portType和message以import方式导入
用cxf+spring发布了webservice,发现生成的wsdl的types,message和portType都以import的方式导入的.. 原因:命名空间问题 我想要生成的wsdl在同个文件中 ...
- 在IIS上发布一个WebService,再发布一个网站调用这个WebService(实例)
首先描述一下先决条件:IIS可用,VS2005可用. 好,现在开始: 首先写一个WebService并把它发布到IIS上: 在IIS上的默认网站下新建一个“虚拟目录”,取名为“webservice1” ...
- 使用CXF+Spring发布WebService,启动报错
使用CXF+Spring发布WebService,启动报错,日志如下: 五月 12, 2017 9:01:37 下午 org.apache.tomcat.util.digester.SetProper ...
- Spring Boot 使用 CXF 调用 WebService 服务
上一张我们讲到 Spring Boot 开发 WebService 服务,本章研究基于 CXF 调用 WebService.另外本来想写一篇 xfire 作为 client 端来调用 webservi ...
- Spring Boot 使用 JAX-WS 调用 WebService 服务
除了 CXF 我们还可以使用 Spring Boot 自身默认的组件 JAX-WS 来实现 WebService 的调用. 本项目源码 github 下载 1 新建 Spring Boot Maven ...
- C# WebService动态调用
前言 站在开发者的角度,WebService 技术确实是不再“时髦”.甚至很多人会说,我们不再用它.当然,为了使软件可以更简洁,更有层次,更易于实现缓存等机制,我是非常建议将 SOAP 转为 REST ...
随机推荐
- jQurey Validation 1.16
https://jeesite.gitee.io/front/jquery-validation/1.16/demo/index.html
- let import export React入门实例教程 connect provider combineReducers 箭头函数 30分钟掌握ES6/ES2015核心内容 Rest babel
let与var的区别 http://www.cnblogs.com/snandy/archive/2015/05/10/4485832.html es6 导入导出 http://www.csdn.ne ...
- 使用@AutoConfigureBefore、After、Order调整Spring Boot自动配置顺序
前言 Spring Boot是Spring家族具有划时代意义的一款产品,它发展自Spring Framework却又高于它,这种高于主要表现在其最重要的三大特性,而相较于这三大特性中更为重要的便是Sp ...
- day58 前端收尾
目录 一.jQuery结束 1 阻止后续事件执行 2 阻止事件冒泡 3 事件委托 4 页面加载 5 动画效果 6 补充知识点 二.前端框架Bootstrap 1 布局容器 2 栅格系统 3 栅格参数 ...
- CSS(六)- 内容布局 - Flexbox
Flexbox是CSS3提供的用于布局的一套新属性,是为了应对行内块.浮动和表格格式产生的问题而生的.其包含针对容器(弹性容器,flex container)和针对其直接子元素(弹性项,flex it ...
- Set 和 Map
1. 数组去重 <script type="text/javascript"> [...new Set(array)] </script> 2. 条件语句的 ...
- DVWA学习记录 PartⅨ
XSS(DOM) 1. 题目 XSS,全称Cross Site Scripting,即跨站脚本攻击,某种意义上也是一种注入攻击,是指攻击者在页面中注入恶意的脚本代码,当受害者访问该页面时,恶意代码会在 ...
- 01 flask源码剖析之werkzurg 了解wsgi
01 werkzurg了解wsgi 目录 01 werkzurg了解wsgi 1. wsgi 2. flask之werkzurg源码流程 3. 总结 1. wsgi django和flask内部都没有 ...
- Python面向对象02/类的空间问题、类与对象之间的关系、类与类之间的关系
Python面向对象02/类的空间问题.类与对象之间的关系.类与类之间的关系 目录 Python面向对象02/类的空间问题.类与对象之间的关系.类与类之间的关系 1. 类的空间问题 2. 类与对象之间 ...
- Idea 自定义快捷代码输入 如syso => System.out.println()
前言 之前一直用的Eclipse System.out.println()的快捷代码输入 是 syso,但是在Idea 不好使用了,后来搜索了一番才知道,在Idea中的快捷输入是 sout,这里我就想 ...