Web Services Tutorial
Web Services Tutorial
Web Services Tutorial
Web Services can convert your application into a Web-application, which can publish its function or
message to the rest of the world.
The basic Web Services platform is XML + HTTP.
1
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.
What is SOAP?
• SOAP is an XML-based protocol to let applications exchange information over HTTP.
• 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
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
2
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
Publish the .asmx file on a server with .NET support, and you will have your first working Web Service.
3
<string xmlns="http://tempuri.org/">38</string>
How To Do It
Here is the code to add the Web Service to a web page:<form
action='http://www.example.com/webservices/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='http://www.example.com/webservices/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 "www.example.com" in the code above with the address of your web site.
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.
By: DataIntegratedEntity22592
Source: http://w3schools.com/webservices/default.asp