Click here to Skip to main content
Click here to Skip to main content

What is Web Service?

By , 7 Mar 2007
Rate this:
Please Sign up or sign in to vote.

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) 
{ 
// any number which is to factorized 
long factorizableNum=999; 
// create a new instance of a web service class 
MyWebService.Factorized myWebService= new Factorized(); 
//Instantiate an AsyncCallback delegate to use as a parameter in the //BeginFactorize method. 
AsyncCallback cb = new AsyncCallback(Class1.FactorizeCallback); 
// Begin the Async call to Factorize, passing in our AsyncCalback delegate //and a reference 
// to our instance of PrimeFactorizer. 
IAsyncResult ar= myWebService.BeginFactor(factorizableNum,cb,myWebService); 
// Keep track of the time it takes to complete the async call 
// as the call proceeds. 
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()); 
} 
} 
// Once the call has completed, you need a method to ensure the 
// thread executing this Main function 
// doesn't complete prior to the call-back function completing. 
Console.Write("Press Enter to quit"); 
Console.ReadLine(); 
} 
private static void FactorizeCallback(IAsyncResult ar) 
{ 
// You passed in our instance of Factorized in the third 
// parameter to BeginFactorize, which is accessible in the 
// AsyncState property. 
MyWebService.Factorized pf = (MyWebService.Factorized) ar.AsyncState; 
long[] results; 
// Get the completed results. 
results = pf.EndFactor(ar); 
//Output the results. 
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 
{ 
/// <summary> 
/// Summary description for Service1. 
/// </summary> 
public class Factorized : System.Web.Services.WebService 
{ 
public Factorized() 
{ 
//CODEGEN: This call is required by the ASP.NET Web Services Designer 
InitializeComponent(); 
} 
#region Component Designer generated code 
//Required by the Web Services Designer 
private IContainer components = null; 
/// <summary> 
/// Required method for Designer support - do not modify 
/// the contents of this method with the code editor. 
/// </summary> 
private void InitializeComponent() 
{ 
} 
/// <summary> 
/// Clean up any resources being used. 
/// </summary> 
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; 
// factorize the number from 2 to factorizableNum/2 
for(i=2;i<(factorizableNum/2);i++) 
{ 
while(check%i==0) 
{ 
outList.Add(i); 
check=check/i; 
} 
} 
//Double-check to see how many prime factors have been added. 
//If none, add 1 and the number. 
j = outList.Count; 
if(j==0) 
{ 
outList.Add(1); 
outList.Add(factorizableNum); 
} 
//Return the results and 
//create an array to hold them. 
long[] primeFactor = new long[j]; 
for (j = 0; j < outList.Count; j++) 
{ 
//Pass the values one by one, making sure 
//to convert them to type ulong. 
primeFactor[j] = Convert.ToInt64(outList[j]); 
} 
return primeFactor; 
} 
catch (Exception) 
{ 
return null; 
} 
} 
} 
} 

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

About the Author

Nakul Lande
Web Developer
United States United States
Optimistic....... and Looking forward

Comments and Discussions

 
GeneralMy vote of 2 PinmemberMember 943842714-Apr-14 20:21 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Mobile
Web01 | 2.8.140415.2 | Last Updated 7 Mar 2007
Article Copyright 2007 by Nakul Lande
Everything else Copyright © CodeProject, 1999-2014
Terms of Use
Layout: fixed | fluid