Introduction
What are Web Services?
- Web services are small units of code
- Web services are designed to handle a limited set of tasks
- Web services use XML based communicating protocols
- Web services are independent of operating systems
- Web services are independent of programming languages
- Web services connect people, systems and devices
Small Units of Code
Web services are small units of code designed to handle a limited set of tasks.
An example of a web service can be a small program designed to supply other applications with the latest stock exchange prices. Another example can be a small program designed to handle credit card payment.
XML Based Web Protocols
Web services use the standard web protocols HTTP, XML, SOAP, WSDL, and UDDI.
HTTP
HTTP (Hypertext Transfer Protocol) is the World Wide Web standard for communication over the Internet. HTTP is standardized by the World Wide Web Consortium (W3C).
XML
XML (eXtensible Markup Language) is a well known standard for storing, carrying, and exchanging data. XML is standardized by the W3C.
You can read more about XML in our XML tutorial.
SOAP
SOAP is a protocol specification that defines a uniform way of passing XML-encoded data. In also defines a way to perform remote procedure calls (RPCs) using HTTP as the underlying communication protocol. SOAP (Simple Object Access Protocol) is a lightweight platform and language neutral communication protocol that allows programs to communicate via standard Internet HTTP. SOAP is standardized by the W3C.
WSDL
WSDL (Web Services Description Language) is an XML-based language used to define web services and to describe how to access them. WSDL is a suggestion by Ariba, IBM and Microsoft for describing services for the W3C XML Activity on XML Protocols.
You can read more about WSDL in our WSDL tutorial.
UDDI
UDDI provides a mechanism for clients to dynamically find other web services. UDDI (Universal Description, Discovery and Integration) is a directory service where businesses can register and search for web services. UDDI is a public registry, where one can publish and inquire about web services.
DISCO is a Microsoft technology for publishing and discovering Web Services. DISCO can define a document format along with an interrogation algorithm, making it possible to discover the Web Services exposed on a given server. DISCO makes it possible to discover the capabilities of each Web Service (via documentation) and how to interact with it. To publish a deployed Web Service using DISCO, you simply need to create a .disco file and place it in the vroot along with the other service-related configuration
Independent of Operating Systems
Since web services use XML based protocols to communicate with other systems, web services are independent of both operating systems and programming languages.
An application calling a web service will always send its requests using XML, and get its answer returned as XML. The calling application will never be concerned about the operating system or the programming language running on the other computer.
Benefits of Web Services
- Easier to communicate between applications
- Easier to reuse existing services
- Easier to distribute information to more consumers
- Rapid development
Web services make it easier to communicate between different applications. They also make it possible for developers to reuse existing web services instead of writing new ones.
Web services can create new possibilities for many businesses because it provides an easy way to distribute information to a large number of consumers. One example could be flight schedules and ticket reservation systems.
DISCO is a Microsoft technology for publishing and discovering Web Services. DISCO can define a document format along with an interrogation algorithm, making it possible to discover the Web Services exposed on a given server. DISCO makes it possible to discover the capabilities of each Web Service (via documentation) and how to interact with it. To publish a deployed Web Service using DISCO, you simply need to create a .disco file and place it in the vroot along with the other service-related configuration
Files with the WSDL extension contain web service interfaces expressed in the Web Service Description Language (WSDL). WSDL is a standard XML document type specified by the World Wide Web Consortium (W3C). WSDL files are used to communicate interface information between web service producers and consumers. A WSDL description allows a client to utilize a web service's capabilities without knowledge of the implementation details of the web service.
Contents of a WSDL File
A WSDL file contains all of the information necessary for a client to invoke the methods of a web service:
The data types used as method parameters or return values
The individual methods names and signatures (WSDL refers to methods as operations)
The protocols and message formats allowed for each method
The URLs used to access the web service
Console application
using System;
using System.Runtime.Remoting;
using System.Runtime.Remoting.Messaging;
using ConsoleApplication1.MyWebService;
namespace ConsoleApplication1
{
class Class1
{
static void <place w:st="on" />Main</place />(string[] args)
{
long factorizableNum=999;
MyWebService.Factorized myWebService= new Factorized();
AsyncCallback cb = new AsyncCallback(Class1.FactorizeCallback);
IAsyncResult ar= myWebService.BeginFactor(factorizableNum,cb,myWebService);
int start = DateTime.Now.Second;
int currentSecond = start;
while (ar.IsCompleted == false)
{
if (currentSecond < DateTime.Now.Second)
{
currentSecond = DateTime.Now.Second;
Console.WriteLine("Seconds Elapsed..." + (currentSecond –
start).ToString());
}
}
Console.Write("Press Enter to quit");
Console.ReadLine();
}
private static void FactorizeCallback(IAsyncResult ar)
{
MyWebService.Factorized pf = (MyWebService.Factorized) ar.AsyncState;
long[] results;
results = pf.EndFactor(ar);
Console.Write("999 factors into: ");
int j;
for (j = 0; j<results.Length;j++)
{
if (j == results.Length - 1)
Console.WriteLine(results[j]);
else
Console.Write(results[j] + ", ");
}
}
}
}
WebService Application
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Web;
using System.Web.Services;
namespace TestWebService1
{
public class Factorized : System.Web.Services.WebService
{
public Factorized()
{
InitializeComponent();
}
#region Component Designer generated code
private IContainer components = null;
private void InitializeComponent()
{
}
protected override void Dispose( bool disposing )
{
if(disposing && components != null)
{
components.Dispose();
}
base.Dispose(disposing);
}
#endregion
[WebMethod]
public long[] Factor(long factorizableNum)
{
ArrayList outList=new ArrayList();
int i,j;
try
{
long check=factorizableNum;
for(i=2;i<(factorizableNum/2);i++)
{
while(check%i==0)
{
outList.Add(i);
check=check/i;
}
}
j = outList.Count;
if(j==0)
{
outList.Add(1);
outList.Add(factorizableNum);
}
long[] primeFactor = new long[j];
for (j = 0; j < outList.Count; j++)
{
primeFactor[j] = Convert.ToInt64(outList[j]);
}
return primeFactor;
}
catch (Exception)
{
return null;
}
}
}
}