Go Back   Wiki NewForum | Latest Entertainment News > Career Forum & Tips > Tech Forum & Tutorial > IT Forum


Web Services Tutorial


Reply
Views: 4764  
Thread Tools Rate Thread
  #1  
Old 05-03-2009, 04:05 PM
welcomewiki welcomewiki is offline
Member
 
Join Date: Dec 2008
Location: India
Posts: 80,566
Default 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.

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.

Reply With Quote
  #2  
Old 05-03-2009, 04:08 PM
welcomewiki welcomewiki is offline
Member
 
Join Date: Dec 2008
Location: India
Posts: 80,566
Default 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 simple 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.
Reply With Quote
  #3  
Old 05-03-2009, 04:09 PM
welcomewiki welcomewiki is offline
Member
 
Join Date: Dec 2008
Location: India
Posts: 80,566
Default 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
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


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
Reply With Quote
  #4  
Old 05-03-2009, 04:10 PM
welcomewiki welcomewiki is offline
Member
 
Join Date: Dec 2008
Location: India
Posts: 80,566
Default 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

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

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.
Reply With Quote
  #5  
Old 05-03-2009, 04:10 PM
welcomewiki welcomewiki is offline
Member
 
Join Date: Dec 2008
Location: India
Posts: 80,566
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:




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

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
Reply With Quote
Reply

New topics in IT Forum





Powered by vBulletin® Version 3.8.10
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
WikiNewForum)