WTP1.0开发WebService之使用WSDL生成Service
2007-03-25 12:36
826 查看
This tutorial shows how to create a simple Web service from a WSDL file.[/i]
author: ZJ 07-3-20
Blog: http://zhangjunhd.blog.51cto.com/
1.确定安装了Apache Tomcat(这里使用Tomcat5.0),新建一个dynamic Web project取名为 AreaProj。
2.示例中使用的WSDL文档。(该文档定义了一个计算长方形面积的服务)
AreaService.wsdl
3.将AreaService.wsdl放在/WebContent下,鼠标右键选中该文件,选择New-Other-WebService,配置如下。
![](http://blog.51cto.com/attachment/200703/200703251174797158931.jpg)
4.一路Next,如果没有启动Tomcat,会提示Start Server。最后选择Finish。
5.在/src下生成部分java文件,其中一个AreaServiceSOAPImpl.java。将其内容修改为如下所示。
![](http://blog.51cto.com/attachment/200703/200703251174797274307.jpg)
6.在/WebContent/wsdl/下会生成AreaServiceSOAP.wsdl。鼠标右键选中该文件,选择New-Other-WebService Client,配置如下。
![](http://blog.51cto.com/attachment/200703/200703251174797363505.jpg)
7.点击两个Next后,到达Client环境配置。配置如下。
![](http://blog.51cto.com/attachment/200703/200703251174797414409.jpg)
8.选择Finish。出现如下画面。
![](http://blog.51cto.com/attachment/200703/200703251174797463479.jpg)
9.选择calculateRectArea进行测试,计算长方形面积。测试结果如下。
![](http://blog.51cto.com/attachment/200703/200703251174797535342.jpg)
10.查看传递的SOAP。
request部分:
![](http://blog.51cto.com/attachment/200703/200703251174797574799.jpg)
response部分:
![](http://blog.51cto.com/attachment/200703/200703251174797610921.jpg)
11.参考资料
Eclipse WTP tutorials.
相关介绍
WTP1.0开发WebService之Java Class实例
author: ZJ 07-3-20
Blog: http://zhangjunhd.blog.51cto.com/
1.确定安装了Apache Tomcat(这里使用Tomcat5.0),新建一个dynamic Web project取名为 AreaProj。
2.示例中使用的WSDL文档。(该文档定义了一个计算长方形面积的服务)
AreaService.wsdl
<?xml version="1.0" encoding="UTF-8"?> <wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://tempuri.org/AreaService/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="AreaService" targetNamespace="http://tempuri.org/AreaService/"> <wsdl:types> <xsd:schema targetNamespace=http://tempuri.org/AreaService/ xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <xsd:element name="area" type="xsd:float"/> <xsd:element name="parameters" type="tns:dimensions"/> <xsd:complexType name="dimensions"> <xsd:sequence> <xsd:element name="width" type="xsd:float"></xsd:element> <xsd:element name="height" type="xsd:float"></xsd:element> </xsd:sequence> </xsd:complexType> </xsd:schema> </wsdl:types> <wsdl:message name="CalculateRectAreaResponse"> <wsdl:part element="tns:area" name="area"/> </wsdl:message> <wsdl:message name="CalculateRectAreaRequest"> <wsdl:part element="tns:parameters" name="parameters"/> </wsdl:message> <wsdl:portType name="AreaService"> <wsdl:operation name="CalculateRectArea"> <wsdl:input message="tns:CalculateRectAreaRequest"/> <wsdl:output message="tns:CalculateRectAreaResponse"/> </wsdl:operation> </wsdl:portType> <wsdl:binding name="AreaServiceSOAP" type="tns:AreaService"> <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/> <wsdl:operation name="CalculateRectArea"> <soap:operation soapAction="http://tempuri.org/AreaService/NewOperation"/> <wsdl:input> <soap:body use="literal"/> </wsdl:input> <wsdl:output> <soap:body use="literal"/> </wsdl:output> </wsdl:operation> </wsdl:binding> <wsdl:service name="AreaService"> <wsdl:port binding="tns:AreaServiceSOAP" name="AreaServiceSOAP"> <soap:address location="http://tempuri.org"/> </wsdl:port> </wsdl:service> </wsdl:definitions> |
![](http://blog.51cto.com/attachment/200703/200703251174797158931.jpg)
4.一路Next,如果没有启动Tomcat,会提示Start Server。最后选择Finish。
5.在/src下生成部分java文件,其中一个AreaServiceSOAPImpl.java。将其内容修改为如下所示。
![](http://blog.51cto.com/attachment/200703/200703251174797274307.jpg)
6.在/WebContent/wsdl/下会生成AreaServiceSOAP.wsdl。鼠标右键选中该文件,选择New-Other-WebService Client,配置如下。
![](http://blog.51cto.com/attachment/200703/200703251174797363505.jpg)
7.点击两个Next后,到达Client环境配置。配置如下。
![](http://blog.51cto.com/attachment/200703/200703251174797414409.jpg)
8.选择Finish。出现如下画面。
![](http://blog.51cto.com/attachment/200703/200703251174797463479.jpg)
9.选择calculateRectArea进行测试,计算长方形面积。测试结果如下。
![](http://blog.51cto.com/attachment/200703/200703251174797535342.jpg)
10.查看传递的SOAP。
request部分:
![](http://blog.51cto.com/attachment/200703/200703251174797574799.jpg)
response部分:
![](http://blog.51cto.com/attachment/200703/200703251174797610921.jpg)
11.参考资料
Eclipse WTP tutorials.
相关介绍
WTP1.0开发WebService之Java Class实例
相关文章推荐
- Spring 集成CXF框架发布Webservice服务 和 使用jdk生成Webservice clinet
- 根据wsdl的url,使用axis1.4生成客户端,并且对webservice进行调用
- WebService从零到项目开发使用1—技术研究之基础篇 WSDL
- Jax-ws 开发webService ,并使用spring注入service类中遇到 空指针
- Jax-ws 开发webService ,并使用spring注入service类中遇到 空指针
- 使用Axis2 wsdl2java命令生成webservice客户端
- 使用axis2解析wsdl生成Webservice客户端代码
- 使用Eclipse及WTP插件开发WebService
- WebService 使用wsdl.exe生成代理类
- webservice,wsdl生成服务端代码,eclipse使用Axis框架生成
- axis 使用 wsdl 文件 生成 webservice的 client 端 ,并传送数据的解决方案
- 根据wsdl的url,使用axis1.4生成客户端,并且对webservice进行调用
- 使用axis2解析wsdl反向生成webservice客户端代码
- MyEclipse使用JAX-WS 2.0生成WebService报错,无法生成WSDL文件
- JAXWS 开发webService ,使用spring注入service类时,无法注入,报空指针
- 使用wsdl2java命令生成webservice本地调用代码
- 使用axis2解析wsdl反向生成webservice客户端
- webService---使用Xfire从WSDL生成客户端(详)
- WebService从零到项目开发使用1—技术研究之基础篇 WSDL
- 使用中国气象局的天气预报webservice,wsdl2java生成JAVA类时报错