一、Introduction to Web Services

Web Services can convert your applications into Web-applications.

Web Services are published, found, and used through the Web.


What You Should Already Know

Before you continue, you should have a basic understanding of the following:

  • HTML
  • XML

If you want to study these subjects first, find the tutorials on our Home page.


What are Web Services?

  • Web services are application components
  • Web services communicate using open protocols
  • Web services are self-contained and self-describing
  • Web services can be discovered using UDDI
  • Web services can be used by other applications
  • XML is the basis for Web services

How Does it Work?

The basic Web services platform is XML + HTTP.

XML provides a language which can be used between different platforms and programming languages and still express complex messages and functions.

The HTTP protocol is the most used Internet protocol.

Web services platform elements:

  • SOAP (Simple Object Access Protocol)
  • UDDI (Universal Description, Discovery and Integration)
  • WSDL (Web Services Description Language)

We will explain these topics later in the tutorial.

二、Why Web Services?

A few years ago Web services were not fast enough to be interesting.

Interoperability has Highest Priority

When all major platforms could access the Web using Web browsers, different platforms could interact. For these platforms to work together, Web-applications were developed.

Web-applications are simply applications that run on the web. These are built around the Web browser standards and can be used by any browser on any platform.


Web Services take Web-applications to the Next Level

By using Web services, your application can publish its function or message to the rest of the world.

Web services use XML to code and to decode data, and SOAP to transport it (using open protocols).

With Web services, your accounting department's Win 2k server's billing system can connect with your IT supplier's UNIX server.


Web Services have Two Types of Uses

Reusable application-components.

There are things applications need very often. So why make these over and over again?

Web services can offer application-components like: currency conversion, weather reports, or even language translation as services.

Connect existing software.

Web services can help to solve the interoperability problem by giving different applications a way to link their data.

With Web services you can exchange data between different applications and different platforms.

三、Web Services Platform Elements

Web Services have three basic platform elements: SOAP, WSDL and UDDI.

What is SOAP?

SOAP is an XML-based protocol to let applications exchange information over HTTP.

Or more simple: SOAP is a protocol for accessing a Web Service.

  • SOAP stands for Simple Object Access Protocol
  • SOAP is a communication protocol
  • SOAP is a format for sending messages
  • SOAP is designed to communicate via Internet
  • SOAP is platform independent
  • SOAP is language independent
  • SOAP is based on XML
  • SOAP is simple and extensible
  • SOAP allows you to get around firewalls
  • SOAP is a W3C standard

Read more about SOAP on our Home page.


What is WSDL?

WSDL is an XML-based language for locating and describing Web services.

  • WSDL stands for Web Services Description Language
  • WSDL is based on XML
  • WSDL is used to describe Web services
  • WSDL is used to locate Web services
  • WSDL is a W3C standard

Read more about WSDL on our Home page.


What is UDDI?

UDDI is a directory service where companies can register and search for Web services.

  • UDDI stands for Universal Description, Discovery and Integration
  • UDDI is a directory for storing information about web services
  • UDDI is a directory of web service interfaces described by WSDL
  • UDDI communicates via SOAP
  • UDDI is built into the Microsoft .NET platform

Read more about UDDI in our WSDL Tutorial.

四、Web Services Example

Any application can have a Web Service component.

Web Services can be created regardless of programming language.


A Web Service Example

In the following example we will use ASP.NET to create a simple Web Service that converts the temperature from Fahrenheit to Celsius, and vice versa:

<%@ WebService Language="VBScript" Class="TempConvert" %>

Imports System
Imports System.Web.Services

Public Class TempConvert :Inherits WebService

<WebMethod()> Public Function FahrenheitToCelsius
(ByVal Fahrenheit As String) As String
  dim fahr
  fahr=trim(replace(Fahrenheit,",","."))
  if fahr="" or IsNumeric(fahr)=false then return "Error"
  return ((((fahr) - 32) / 9) * 5)
end function

<WebMethod()> Public Function CelsiusToFahrenheit
(ByVal Celsius As String) As String
  dim cel
  cel=trim(replace(Celsius,",","."))
  if cel="" or IsNumeric(cel)=false then return "Error"
  return ((((cel) * 9) / 5) + 32)
end function

end class

This document is saved as an .asmx file. This is the ASP.NET file extension for XML Web Services.


Example Explained

Note: To run this example, you will need a .NET server.

The first line in the example states that this is a Web Service, written in VBScript, and has the class name "TempConvert":

<%@ WebService Language="VBScript" Class="TempConvert" %>

The next lines import the namespace "System.Web.Services" from the .NET framework:

Imports System
Imports System.Web.Services

The next line defines that the "TempConvert" class is a WebService class type:

Public Class TempConvert :Inherits WebService

The next steps are basic VB programming. This application has two functions. One to convert from Fahrenheit to Celsius, and one to convert from Celsius to Fahrenheit.

The only difference from a normal application is that this function is defined as a "WebMethod()".

Use "WebMethod()" to convert the functions in your application into web services:

<WebMethod()> Public Function FahrenheitToCelsius
(ByVal Fahrenheit As String) As String
  dim fahr
  fahr=trim(replace(Fahrenheit,",","."))
  if fahr="" or IsNumeric(fahr)=false then return "Error"
  return ((((fahr) - 32) / 9) * 5)
end function

<WebMethod()> Public Function CelsiusToFahrenheit
(ByVal Celsius As String) As String
  dim cel
  cel=trim(replace(Celsius,",","."))
  if cel="" or IsNumeric(cel)=false then return "Error"
  return ((((cel) * 9) / 5) + 32)
end function

Then, end the class:

end class

Publish the .asmx file on a server with .NET support, and you will have your first working Web Service.

Look at our example Web Service


ASP.NET Automates the Process

With ASP.NET, you do not have to write your own WSDL and SOAP documents.

If you look closer at our example Web Service, you will see that ASP.NET has automatically created aWSDL and SOAP request.

五、Web Services How to Use

Using the Web Service Example

In the previous page we created a Web service.

The FahrenheitToCelsius() function can be tested here: FahrenheitToCelsius

The CelsiusToFahrenheit() function can be tested here: CelsiusToFahrenheit

These functions will send an XML response like this:

<?xml version="1.0" encoding="utf-8" ?>
<string xmlns="http://tempuri.org/">38</string>

Put the Web Service on Your Web Site

Using a form and the HTTP POST method, you can put the web service on your site, like this:

Fahrenheit to Celsius:
 
Celsius to Fahrenheit:
 

How To Do It

Here is the code to add the Web Service to a web page:

<form action='tempconvert.asmx/FahrenheitToCelsius'
method="post" target="_blank">
<table>
  <tr>
    <td>Fahrenheit to Celsius:</td>
    <td>
    <input class="frmInput" type="text" size="30" name="Fahrenheit">
    </td>
  </tr>
  <tr>
    <td></td>
    <td align="right">
     <input type="submit" value="Submit" class="button">
     </td>
  </tr>
</table>
</form>

<form action='tempconvert.asmx/CelsiusToFahrenheit'
method="post" target="_blank">
<table>
  <tr>
    <td>Celsius to Fahrenheit:</td>
    <td>
    <input class="frmInput" type="text" size="30" name="Celsius">
    </td>
  </tr>
  <tr>
    <td></td>
    <td align="right">
    <input type="submit" value="Submit" class="button">
    </td>
  </tr>
</table>
</form>

Substitute the "tempconvert.asmx" with the address of your web service like:

http://www.example.com/webservices/tempconvert.asmx

六、You Have Learned Web Services, Now What?

Web Services Summary

This tutorial has taught you how to convert your applications into web-applications.

You have learned how to use XML to send messages between applications.

You have also learned how to export a function (create a web service) from your application.


Now You Know Web Services, What's Next?

The next step is to learn about WSDL and SOAP.

WSDL

WSDL is an XML-based language for describing Web services and how to access them.

WSDL describes a web service, along with the message format and protocol details for the web service.

If you want to learn more about WSDL, please visit our WSDL tutorial.

SOAP

SOAP is a simple XML-based protocol that allows applications to exchange information over HTTP.

Or more simply: SOAP is a protocol for accessing a web service.

If you want to learn more about SOAP, please visit our SOAP tutorial.

Web Services教程相关推荐

  1. java web 教程_Java Web服务教程

    java web 教程 Welcome to the Java Web Services Tutorial. Here we will learn about web services, useful ...

  2. 零基础 Amazon Web Services (AWS) 入门教程图文版(三)

    原则上WDCP安装好了,就可以直接使用了,FTP.MySQL什么的应有尽有.但是本站Amazon AWS -- 免费的午餐不好吃一文中说到过这个问题,直接用WDCP的MySQL会导致EBS的I/O急剧 ...

  3. 零基础 Amazon Web Services (AWS) 入门教程图文版(四)

    自上一篇之后,5天过去了,这篇文章总算是挤出来了... 其实看不看无所谓啦,都说了WDCP非常适合小白,随便折腾.要是折腾的时候遇到什么问题,欢迎留言探讨~ 五.新建站点 登录WDCP后台,首次登录会 ...

  4. 零基础 Amazon Web Services (AWS) 入门教程图文版(二)

    上一篇讲到,主机正常运转了.但是此时如果直接访问公网IP是打不开网页的,因为主机上没有搭建Web服务器环境,防火墙也没有开放80端口,并且我们没有上传任何网页文件.所以这一篇主要介绍服务器环境的搭建. ...

  5. 零基础 Amazon Web Services (AWS) 入门教程 (列表)

    在 Amazon Web Services 上托管 Web 应用程序 Web 应用程序 是指用户通过 Web 浏览器或专门的 Web 客户端访问的任何软件.Web 应用程序通常具有逻辑层级结构.例如, ...

  6. 零基础 Amazon Web Services (AWS) 入门教程图文版(一)

    现在小站唯一的流量都靠AWS这个关键词了,刚好要用AWS重新建站,所以从头开始记录一遍吧. 所谓零基础,就是你可以没有任何AWS使用经历,仍然能够按照教程操作下去.所谓图文版,就是建议手机用户在没有连 ...

  7. MyEclipse开发教程:使用REST Web Services管理JPA实体(四)

    2019独角兽企业重金招聘Python工程师标准>>> MyEclipse 在线订购年终抄底促销!火爆开抢>> MyEclipse最新版下载 使用REST Web Ser ...

  8. web services学习笔记(摘自菜鸟教程)

    1.什么是web services Web Services是应用程序组件 Web Services使用开放协议进行通信 Web Services是独立的(self-contained)并可自我描述 ...

  9. 雷林鹏分享:Ruby Web Services 应用 - SOAP4R

    Ruby Web Services 应用 - SOAP4R 什么是 SOAP? 简单对象访问协议(SOAP,全写为Simple Object Access Protocol)是交换数据的一种协议规范. ...

最新文章

  1. Python进程和线程保姆式教学,1个台机子多只手干活的秘籍
  2. COLING 2020 | CharBERT:字符敏感的预训练语言模型
  3. boost::graph模块演示 GGCL Vertex 接口
  4. 全国计算机等级考试题库二级C操作题100套(第23套)
  5. 中国“新基建”7大产业链全景图!(附500家企业超全名单!)
  6. python中什么叫类、什么叫对象_python中的类面向对象的基本概念!
  7. Error building SqlSession问题
  8. linux 三维数据绘图软件,Linux下开发基于.NET的三维绘图程序
  9. C#注册类方法到Lua
  10. WPF中改进自定义Command一些想法
  11. matlab改变示波器颜色,[转载]matlab/simulink 示波器颜色设置
  12. python数字信号处理pdf_数字信号处理
  13. EXCEL VBA编程入门二:什么是VBA?什么是EXCEL VBA?
  14. a59s刷机包卡刷 oppo_OPPO A59s 5.1 ROM刷机包 ColorOS 精简卡刷包 ROOT权限
  15. android实现语音聊天功能,为实现Android语音聊天室开发,语音聊天室软件源码该如何搭建...
  16. 2021年中国图书出版行业经营现状及重点企业对比分析:凤凰传媒优势明显[图]
  17. 国企程序员可以干多久
  18. SiTime硅晶振温度传感技术
  19. Python-子列表最大长度
  20. Ubuntu把不需要的模块blacklist掉

热门文章

  1. 电脑蓝屏重启后,js文件损坏或断电重启后文件损坏
  2. Pulsar 2021 年用户报告要点总结
  3. 超级计算器 - 网易出品的数学好助手
  4. Flutter 云音乐
  5. 新增linux驱动并重新编译内核,【转】配置并编译内核[更新到linux-2.6.29.2]
  6. jsp标签jsp:useBean用法
  7. 今天小鱼搬家,简单说说Gazebo
  8. NC与单一窗口数据对接丨外贸软件
  9. 《安富莱嵌入式周报》第261期:2022.04.11--2022.04.17
  10. iOS 集成通联支付