免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1333 | 回复: 0
打印 上一主题 下一主题

Creating Bottom Up Web Service [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2007-01-10 10:43 |只看该作者 |倒序浏览

Creating Bottom Up Web Service


By Kathy Chan
June 29, 2006



This document is one of a series of tutorials to demonstrate the use of the Web Services tools in the Web Tools Platform Project using the WTP 1.5 drivers.

This tutorial shows how to create a simple Web service and Web service client from a Java class. The Java class in this scenario converts between the Celsius and Farenheit temperature scales.




Before creating the Web service, there are two prerequisites:


  • Install Apache Tomcat


  • Create a dynamic Web project
    called ConverterProj .



  • Import the
    wtp/Converter.java
    class into ConverterProj/src (be sure to preserve the package).
  • Select the Converter.java file.
  • Open File -> New -> Other... -> Web Services -> Web Service.
  • Click Next.
  • Move the Service slider to the Start Service position .
  • Move the Client slider to the Test Client position .
  • Select Monitor the Web service .
  • If you want to choose a server different from the one defaulted by the wizard, click the Server project link to
    select a server
    .
  • Result:


  • Click Finish .
  • It will take about one minute for the wizard to assemble the Web service and Web service client Web projects, start Apache Tomcat, and deploy the projects to Tomcat. Once finished, the generated Sample JSP Web application will appear in the browser view, maximized here for clarity:


  • Under Methods , click on celsiusToFarenheit(float) .
  • Under Inputs , enter 37 into the celsius entry field.
  • Click on Invoke. In the Result view, you should get a response of 98.6.



  • Since you selected the "Monitor Web service" checkbox, a TCP/IP port is automatically created on the Tomcat server. When you invoke the Web service, the TCP/IP Monitor view comes up automatically showing the SOAP message request and response. Double-click on the TCP/IP Monitor view and select XML view in the drop-down combo for both request and response. Result:




    The Web Service wizard is orchestrating the end-to-end generation, assembly, deployment, installation and execution of the Web service, Web service client, and sample JSPs. In this scenario, we clicked Finish on page one. In effect, this is allowing the wizard to pick reasonable defaults according to the basic high-level choices made on the first page. If you repeat this scenario, but use the Next button to work through the wizard, you will learn more about the kinds of choices that are available and the kinds of defaults being assumed.

    After completing this scenario, the WSDL for the Converter Web service can be found in ConverterProj/WebContent/wsdl/Converter.wsdl.

    Now that your Web service is running, there are a few interesting things you can do with this WSDL file. Examples:

  • You can double-click on the WSDL to open the WSDL graphical editor.
  • You can right-click on the WSDL and choose Web Services -> Test with Web Services Explorer to test the service.
  • You can right-click on the WSDL and choose Web Services -> Publish WSDL file to publish the service to a public UDDI registry.
  • You can click on the WSDL and choose New -> Other... -> Web Services -> Web Service Client to generate a Web service client. Note, however, that we have already witnessed the internal and visual features of the Web Service Client wizard since, in addition to being its own wizard, it is quite literally embedded within the larger Web Service wizard.


    本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u/26155/showart_229367.html
  • 您需要登录后才可以回帖 登录 | 注册

    本版积分规则 发表回复

      

    北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
    未成年举报专区
    中国互联网协会会员  联系我们:huangweiwei@itpub.net
    感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

    清除 Cookies - ChinaUnix - Archiver - WAP - TOP