发布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的更多相关文章

  1. 调用已发布的WebService

    WebService服务演示 登录http://www.webxml.com.cn

  2. CXF整合Spring发布WebService实例

    一.说明: 上一篇简单介绍了CXF以及如何使用CXF来发布一个简单的WebService服务,并且介绍了客户端的调用. 这一篇介绍如何使用CXF与spring在Web项目中来发布WebService服 ...

  3. CXF2.7整合spring发布webservice

    ---------==========--服务端发布webservice-=============-------- 1.需要的jar包: 2.包结构 3.代码 1.实体类 package cn.ql ...

  4. 解决cxf+spring发布的webservice,types,portType和message以import方式导入

    用cxf+spring发布了webservice,发现生成的wsdl的types,message和portType都以import的方式导入的.. 原因:命名空间问题 我想要生成的wsdl在同个文件中 ...

  5. 在IIS上发布一个WebService,再发布一个网站调用这个WebService(实例)

    首先描述一下先决条件:IIS可用,VS2005可用. 好,现在开始: 首先写一个WebService并把它发布到IIS上: 在IIS上的默认网站下新建一个“虚拟目录”,取名为“webservice1” ...

  6. 使用CXF+Spring发布WebService,启动报错

    使用CXF+Spring发布WebService,启动报错,日志如下: 五月 12, 2017 9:01:37 下午 org.apache.tomcat.util.digester.SetProper ...

  7. Spring Boot 使用 CXF 调用 WebService 服务

    上一张我们讲到 Spring Boot 开发 WebService 服务,本章研究基于 CXF 调用 WebService.另外本来想写一篇 xfire 作为 client 端来调用 webservi ...

  8. Spring Boot 使用 JAX-WS 调用 WebService 服务

    除了 CXF 我们还可以使用 Spring Boot 自身默认的组件 JAX-WS 来实现 WebService 的调用. 本项目源码 github 下载 1 新建 Spring Boot Maven ...

  9. C# WebService动态调用

    前言 站在开发者的角度,WebService 技术确实是不再“时髦”.甚至很多人会说,我们不再用它.当然,为了使软件可以更简洁,更有层次,更易于实现缓存等机制,我是非常建议将 SOAP 转为 REST ...

随机推荐

  1. cron表达式详解,cron表达式写法,cron表达式例子

    (cron = "* * * * * *") cron表达式格式:{秒数} {分钟} {小时} {日期} {月份} {星期} {年份(可为空)}例  "0 0 12 ? ...

  2. object detection api调参详解(兼SSD算法参数详解)

    一.引言 使用谷歌提供的object detection api图像识别框架,我们可以很方便地重新训练一个预训练模型,用于自己的具体业务.以我所使用的ssd_mobilenet_v1预训练模型为例,训 ...

  3. RSS阅读器推荐

    http://www.feeddemon.com/ Windows,Free (完)

  4. Data types 'int' and 'float'

    The type int means that the variables listed are integers; by contrast with float, which means float ...

  5. Appium移动端自动化测试--搭建模拟器和真机测试环境

    详细介绍安装Android Studio及Android SDK.安装Appium Server. 文章目录如下 目录 文章目录如下 模拟器--安装Android Studio及Android SDK ...

  6. HDU 5969 最大的位或 (思维,贪心)

    HDU 5969 最大的位或 题目大意 B君和G君聊天的时候想到了如下的问题. 给定自然数\(l\)和\(r\) ,选取\(2\)个整数\(x,y\)满足\(l <= x <= y < ...

  7. BUUCTF-Crypyo-No.1

    我我我我我又来惹~~~~* MD5 flag{admin1} 看我回旋踢 凯撒密码 flag{5cd1004d-86a5-46d8-b720-beb5ba0417e1} Url编码 flag{and ...

  8. [开源][示例更新]eCharts配置简化包OptionCreator[typescript版]

    前言 eCharts作为国内优秀的开源图表工具,功能强大,但是使用中也存在一定的问题. 文档更新较慢,文档说明不详细. 前端使用的弱类型语言,数据结构在灵活的同时,也容易造成一些问题.例如某些属性到底 ...

  9. [JAVA]使用字节流拷贝文件

    import java.io.*; /** * @Description: * @projectName:JavaTest * @see:PACKAGE_NAME * @author:郑晓龙 * @c ...

  10. meta viewport相关

    <!DOCTYPE html> H5标准声明,使用 HTML5 doctype,不区分大小写 <head lang=”en”> 标准的 lang 属性写法 <meta c ...