【开发环境】

  • Web Service 服务器端开发工具:RAD(Eclipse内核)
  • Web Service 服务器:IBM WebSphere v8.5
  • REST/SOAP:SOAP(JAX-WS/SAAJ:JAX-WS)

功能非常初级,客户端→服务器端 input 一个字符串xxx,服务器端返回“xxx 您好!现在时间是:2018年3月17日23:57:41”

参考资料:http://blog.csdn.net/yangwenxue_admin/article/details/51059125 (部分参考)

  • 开发服务器端(本文)
  • 开发客户端(请参考↑的参考资料,本文略)

第一步、开发服务器端

每个Web Service组件需要2个部分:接口和实现类。← 似乎只有类就行,这个例子是我第一个WebService 项目,先按参考资料模仿着做,以后再逐渐追加更多的内容。

1、新建Dynamic Web Project工程 TestWebService。(如果在Wizards看不到,勾选Show all wizards)

我的RAD环境和Websphere是配置好的,也可以用其他开发环境和服务器,请确保服务器能正确启动。

2、在工程中创建包 test.ws.soap (创建包不是必要的,不过是好习惯)

3、开发一个 WebService 业务接口,方法使用@WebService修饰。

在包中创建interface如下,WebInterface。

 package test.ws.soap;

 import javax.jws.WebService;

 @WebService
public interface WebInterface { String WebMethod(String str); }

4、写一个这个接口的实现类 WebClass,也需要使用@WebService修饰,并指定所需要实现的接口、及服务名称。

 package test.ws.soap;

 import javax.jws.WebService;
import java.util.Date; @WebService(endpointInterface="test.ws.soap.WebInterface",serviceName="TestWS")
public class WebClass implements WebInterface { @Override
public String WebMethod(String str) { return str+" Hello! now is "+new Date();
}
}

5、在浏览器中输入:http://127.0.0.1:9080/TestWebService/TestWS?wsdl 查看结果,如果成功生成如下 WSDL 文档则表示 Web Service 暴露成功。

http://127.0.0.1:9080/工程名/服务名?wsdl

http://127.0.0.1:9080/TestWebService/TestWS?wsdl

WSDL 文档

WSDL 划重点 类=端口 port,方法=操作 operation,参数=消息 message

WSDL 更详细的说明,参考:学习 WebService 第二步:知识准备——WSDL文件解析

<definitions name="TestWS" targetNamespace="http://soap.ws.test/">

<types>

<xsd:schema>

<xsd:import namespace="http://soap.ws.test/"

schemaLocation="TestWS_schema1.xsd" />

</xsd:schema>

</types>

<message name="WebMethod">

<part name="parameters" element="tns:WebMethod">

</part>

</message>

<message name="WebMethodResponse">

<part name="parameters" element="tns:WebMethodResponse">

</part>

</message>

<portType name="WebInterface">

<operation name="WebMethod">

<input message="tns:WebMethod"

wsam:Action="http://soap.ws.test/WebInterface/WebMethodRequest">

</input>

<output message="tns:WebMethodResponse"

wsam:Action="http://soap.ws.test/WebInterface/WebMethodResponse">

</output>

</operation>

</portType>

<binding name="WebClassPortBinding" type="tns:WebInterface">

<soap:binding style="document"

transport="http://schemas.xmlsoap.org/soap/http" />

<operation name="WebMethod">

<soap:operation soapAction="" />

<input>

<soap:body use="literal" />

</input>

<output>

<soap:body use="literal" />

</output>

</operation>

</binding>

<service name="TestWS">

<port name="WebClassPort" binding="tns:WebClassPortBinding">

<soap:address location="http://127.0.0.1:9080/TestWebService/TestWS" />

</port>

</service>

</definitions>

第一步、开发客户端

先不做了,因为主要想用SoapUI测试WebService API,所以做个Server端即可,Client端,大家有兴趣请参考:http://blog.csdn.net/jackphang/article/details/8788178

学习 WebService 第三步:一个简单的实例(RAD+WAS 8.5开发SOAP项目)的更多相关文章

  1. maven权威指南学习笔记(三)——一个简单的maven项目

    目标: 对构建生命周期 (build  lifecycle),Maven仓库 (repositories),依赖管理 (dependency management)和项目对象模型 (Project O ...

  2. Django学习 之 Django安装与一个简单的实例认识

    一.Django简介 1.MVC与MTV模型 (1)MVC模型 Web服务器开发领域里著名的MVC模式,所谓MVC就是把Web应用分为模型(M),控制器(C)和视图(V)三层,他们之间以一种插件式的. ...

  3. 学习 WebService 第三步:一个简单的实例(SoapUI测试REST项目)

    原文地址:SOAPUI测试REST项目(六)——REST服务和WADL ↑↑↑ 原文用的SoapUI,2018-3-19时,这个软件已经更名为ReadyAPI(集成了SoapUI),因此下文中我重新截 ...

  4. 响应式编程笔记三:一个简单的HTTP服务器

    # 响应式编程笔记三:一个简单的HTTP服务器 本文我们将继续前面的学习,但将更多的注意力放在用例和编写实际能用的代码上面,而非基本的APIs学习. 我们会看到Reactive是一个有用的抽象 - 对 ...

  5. 学习MQ(三) 一个实例

    学习MQ(三) 一个实例. 现在有两台机器A和B,分别安装了MQ6.0,我要通过MQ进行A和B之间的双向通信. 我打算分两步,第一步:实现A到B的数据传输. 在A上: 1.创建队列管理器 QM_100 ...

  6. C语言入门教程: 一个简单的实例

    对于学习要保持敬畏! 语言不只是一种工具,还是一种资源,因此,善待它,掌握它!   我们知道,对于未知通常都会充满好奇和畏惧,既想了解它,又害怕神秘面纱隐藏的不确定性.对于一门编程语言同样如此,我将以 ...

  7. 【Python学习笔记三】一个简单的python爬虫

    这里写爬虫用的requests插件 1.一般那3.x版本的python安装后都带有相应的安装文件,目录在python安装目录的Scripts中,如下:   2.将scripts的目录配置到环境变量pa ...

  8. 【Java学习笔记】如何写一个简单的Web Service

    本Guide利用Eclipse以及Ant建立一个简单的Web Service,以演示Web Service的基本开发过程: 1.系统条件: Eclipse Java EE IDE for Web De ...

  9. Linux内核分析 笔记三 构造一个简单的Linux系统MenuOS ——by王玥

    一.知识点总结 (一)Linux源代码简介 arch/x86目录下的代码是我们重点关注的 内核启动相关代码都在init目录下 start_kernel函数相当于普通C程序的main函数 linux的核 ...

随机推荐

  1. Core Data stack

    https://developer.apple.com/library/content/documentation/DataManagement/Devpedia-CoreData/coreDataS ...

  2. VIM+ctags+cscope用法

    使用vim + cscope/ctags,就能够实现Source Insight的功能,可以很方便地查看分析源代码.   关键词: vim, cscope, ctags, tags   1. 查看vi ...

  3. PhoneGap+JQuery Mobile移动应用开发学习笔记

    最近一直在学习使用PhoneGap+JQuery Mobile的开发框架开发Android应用,抛开这个框架的运行效率不说,暂且将使用中遇到的问题进行一下整理. 1.JS文件引用顺序 也许在进行web ...

  4. LeetCode_6

    问题: 6. Z字形变换 链接:https://leetcode-cn.com/problems/zigzag-conversion/description/ 分析: A 仿真方法 直接模拟整个过程, ...

  5. ubuntu中卸载没有安装完全的软件包

    sudo apt-get autoclean sudo apt-get clean sudo apt-get autoremove

  6. leetcode-24-exercise

    506. Relative Ranks 解题思路: 使用priority_queue.它在插入时会将数据按照由大到小的顺序插入,自然排序了.所以插入时考虑插入pair<nums[i],i> ...

  7. stm32启动地址

    理论上,CM3中规定上电后CPU是从0地址开始执行,但是这里中断向量表却被烧写在0x0800 0000地址里(Flash memory启动方式),那启动时不就找不到中断向量表了?既然CM3定下的规矩是 ...

  8. poj-3278 catch that cow(搜索题)

    题目描述: Farmer John has been informed of the location of a fugitive cow and wants to catch her immedia ...

  9. 思维水题:UVa512-Spreadsheet Tracking

    Spreadsheet Tracking Data in spreadsheets are stored in cells, which are organized in rows (r) and c ...

  10. German Collegiate Programming Contest 2018​ B. Battle Royale

    Battle Royale games are the current trend in video games and Gamers Concealed Punching Circles (GCPC ...