Friday 23 November 2012

What are Web Services?





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.

1. Web services use XML based communicating protocols

Web services use the standard web protocols HTTP, XML, SOAP, WSDL, and UDDI.

1. 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.
2. 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.

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.

3. 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


2. Web services are independent of operating systems
3. Web services are independent of programming languages

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

    1. Easier to communicate between applications
    2. Easier to reuse existing services
    3. Easier to distribute information to more consumers
    4. Rapid development

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

DISCO File in More Details

1. The .disco document is an XML document that simply contains links to other resources that describe the Web Service.
Eg:

<?xml version="1.0" encoding="utf-8"?>
<discovery xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.xmlsoap.org/disco/">
  <contractRef ref="http://localhost:2585/WebService1/Service.asmx?wsdl" docRef="http://localhost:2585/WebService1/Service.asmx" xmlns="http://schemas.xmlsoap.org/disco/scl/" />
 
    <!-- reference to other DISCO document -->
  <discoveryRef ref="related-services/default.disco"/>

  <soap address="http://localhost:2585/WebService1/Service.asmx" xmlns:q1="http://tempuri.org/" binding="q1:ServiceSoap" xmlns="http://schemas.xmlsoap.org/disco/soap/" />
  <soap address="http://localhost:2585/WebService1/Service.asmx" xmlns:q2="http://tempuri.org/" binding="q2:ServiceSoap12" xmlns="http://schemas.xmlsoap.org/disco/soap/" />
</discovery>

2. The main element is contractRef, which belongs to a different namespace than the rest of the DISCO-related elements. contractRef has two attributes, ref and docRef, which point to the WSDL and documentation files for a given Web Service.
<contractRef ref="http://.../Service.asmx?wsdl" docRef="http://.../Service.asmx" xmlns="http://schemas.xmlsoap.org/disco/scl/" />

3. The discoveryRef element lets you link the given DISCO document to other DISCO documents.
  This linking allows you to create a Web of related DISCO documents spanning multiple machines and even multiple organizations.
  This is especially useful if the DISCO client utility provides a mechanism to traverse the links. These are the only elements that you have to be concerned about in the DISCO namespace.
 
<discoveryRef ref="related-services/default.disco"/>


Difference between Disco,UDDI,WSDL

1. Disco
The Web Service Discovery Tool (DISCO) is used to discover the URLs of XML Web Services located on a Web server and saves documents related to each XML service on a local disk. The DISCO takes the URL and discovers and produce publishes discovery documents (.wsdl, .xsd, .disco and .dicomap files) as arguments.

2. UDDI
Universal Description, Discovery and Integration (UDDI) is a platform independent framework functioning like a directory that provides a mechanism to locate and register web services on the internet.

3. WSDL
Web Service Discovery Language (WSDL) is a markup language that describes the web service.

1. 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
2. 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
3. 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

 1. Caching WebServices

Often a WebService will return the same results over multiple calls, so it makes sense to cache the information to speed things up a little. Doing so in ASP.NET is as simple as adding a CacheDuration attribute to your WebMethod:

[WebMethod(CacheDuration = 30)]
public ClientData[] GetClientData(int Number)
{
}

You can also specify the CacheDuration using a constant member variable in your class:

private const int CacheTime = 30; // seconds

[WebMethod(CacheDuration = CacheTime)]
public ClientData[] GetClientData(int Number)
{
}
2. Adding Descriptions to your WebMethods

In the default list of WebMethods created when you browse to the .asmx file it's nice to have a description of each method posted. The Description attribute accomplishes this.

[WebMethod(CacheDuration = 30,
Description="Returns an array of Clients.")]
public ClientData[] GetClientData(int Number)
{
}

3. Deploying the WebService

1. We need to create a directory for our service (or use an existing directory) for our .asmx file
2. we need to have the service's assembly in the application's bin/ directory.
1. Either place the .asmx file in a subdirectory on your website and place the assembly in the /bin folder in your website's root.
2. OR place the /bin in the subdirectory containing the .asmx file and mark that directory as an application

If you choose to create a separate directory and mark it as an application then Within this directory you need to add the following files and directories:

1. MyService.asmx This file acts as the URL for your service
2. MyService.disco The discovery document for your service
3. web.config Configuration file for your service that overrides default web settings (optional).
4. /bin This directory holds the assembly for your service
5. /bin/MyService.dll The actual service asembly.














No comments:

Post a Comment

IE7 Issues Text Indent

                 Unfortunately IE 7 is still widespread among the users hence while theming we have to give special importance to the grea...