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 ...
随机推荐
- 解决IE浏览器中点击按钮上传无效的问题
前几天写了上传功能,点击按钮上传,在谷歌中是没有任何问题的: 但是在IE浏览器中点击没有任何效果 源代码如下: 后来发现在Firefox.IE浏览器中button标签内部可以含有其他标签,但是不能对 ...
- for循环里的break,continue和return有什么差别
break: 此语句导致程序终止包含它的循环,并进行程序的下一阶段(整个循环后面的语句),即,不是跳到下一个循环周期而是退出循环.如果break语句包含在嵌套循环里,它只跳出最里面的循环. 如下代码 ...
- 【Xamarin.Forms 1】App的创建与运行
引言 本篇文章将从介绍Xamarin.Forms创建开始. 开发环境 Visual Studio 2019 16.6.2 Xamarin.Forms 4.6.0.726 Android 5.0 (AP ...
- Sharepoint 2013设置customErrors
原文地址:http://www.cnblogs.com/renzh/archive/2013/03/05/2944309.html#3407239 一.首先设置IIS中的Web.config文件 找到 ...
- 让网页变灰的实现_网站蒙灰CSS样式总汇
每次全国哀悼日,各大网站首页都变成了灰色,添加以下全局CSS样式,可以实现此效果: 方法一 html { -webkit-filter: grayscale(100%);filter:progid:D ...
- 「疫期集训day0」启程
看了看几乎所有学长都是写的博客,所以写的博客 由于是第一回集训,考得都是老题(虽然有些还不会) 感受1:我调试好蒻呃,调试巨蒻,T1lis模板5分切,结果T2T3T4调了将近了两个小时,先是T2路径输 ...
- 如何科学地完成一场 AR 发布会?全在这份超细节活动策划 Xmind 里了
你们在哪个酒店搭的景? 5 月 28 日,网易智慧企业完成了一场实景人物拍摄 + 虚拟舞台渲染的 AR 线上见面会.非常有趣的是,在直播过程中,不止一位观众问我们,“你们是在哪个酒店搭的景?”.看来我 ...
- unity spine 对翻转和大小的控制
spine-unity怎么决定我的Spine模型的大小? Spine使用 1像素:1单位.意思是,如果你只是包含图像在你的骨架中,并且没有任何旋转和缩放,在Spine中该图像的1个像素就对应1个单位高 ...
- VS插件 resharper安装破解教程
https://masuit.com/20 ReSharper是一款由jetbrains开发的针对C#, VB.NET, ASP.NET, XML,和XAML的编辑器.沿袭了jetbrains开发工具 ...
- Jmeter系列(40)- 详解 Jmeter CLI 模式
如果你想从头学习Jmeter,可以看看这个系列的文章哦 https://www.cnblogs.com/poloyy/category/1746599.html 什么是 CLI 模式 CLI = Co ...