WebServices in .Net

Definition

It is a technology introduced by Microsoft in .NET to provide distributed services over network.
Web Service performs the distribution of the logic always in a xml standard.

History

To develop distributed services many technologies are available in the market like DCOM, CORBA, RMI etc. before .NETPicture4

Advantages

  • Easy to develop and use
  • Cross application communication
  • Cross platform Communication
  • Cross Language Communication
  • Supports Firewalls for Security reasons

Standards of Web Services

SOAP (Simple Object Access Protocol)

  • This standard is used for data transformation and data conversion.
  • It contains XML which is the universal understandable format which is used for transferring the request and response in XML format which is called as SOAP Envelope.
  • To take the SOAP Envelope b/w client and service universal communication protocol is used i.e. HTTP
  • Because its port number is configure on most of the firewalls and proxy.

WSDL (Web Service Description language)

  • This standard will describe a web service in an XML Schema.
  • It provides the description about the methods available, method parameters list, type and the return type of the method.
  • It also specifies how the request and responses are perform with the protocols along with the path of a web service.

DISCO (Discovery Standards)

  • This file will maintains the links of WSDL.

UDDI (Universal Discovery Description Integration)

  • It is a centralized repository where all the web services links are maintained in terms of discovery files. (www.UDDI.org)

Architecture

Local Architecture

Picture2

 

  1. When a Client app gives a request it will search the web service and the WSDL file of that web service and the WSDL file of that web service is return back to the client program.
  2. The client program give the WSDL file to proxy class which checks the your request in the description and generates the request object by binding, parameter list, Type and return type.
  3. Request object is converted to XML standard which is called SOAP request Envelope.
  4. SOAP request Envelope is transfer to server using http protocol
  5. The Soap server on the web server will accept the soap request envelope and converts it to an ordinary request object then forward into the web services.
  6. Web service will process the request and gives the response to the SOAP server.
  7. SOAP server will convert the response to SOAP response envelope send it back to the client using http protocol.
  8. The proxy class on the client machine converts the SOAP response object to display the output.

Global Architecture

Picture3

 

  1. When a client wants to search a web service or access a web service the request is first accepted by the UDDI server.
  2. UDDI contains that web service discovery files.
  3. UDDI server choose the discovery file according to the request and return the link of WSDL file to the client.
  4. The client program will give the request to the WSDL file. Then web service will returns the WSDL file to the client.
  5. Remaining steps are same as Local Architecture.

Developing Web Service in ASP.NET

  1. Web Services are stateless
  2. They should save with .asmx(Active Server Method extension) extension.
  3. The method which you want to provide for internet accessibility those should be declare with [WebMethod] attribute.
  4. To develop web service in ASP.NET, .NET framework has provided System.Web.Services namespace.

Developing a Web Service in Notepad

<%@ WebService Language=“C#” Class=“Sample”%>
using System;
using System.Web.Services;
public class Sample
{
[WebMethod]
public int Sum(int a, int b)
{
return a+b;
}
}

  • Save the file with .asmx extension and copy the file to the virtual directory.
  • To test the WebService and to view the description go to browser and type the url of the like ex: http://localhost/aspnet/first.asmx

State Management with Web Services

  • As Web Services are stateless technology whose memory will be allocated with every request and automatically destroys with every response.
  • So to maintain some information on the web service hosted system for a specific time interval we can use state management.
  • State management with web service always supports Server Side State management by using 3 concepts
    1. Sessions  2. Applications 3. Caching

    Sessions with Web Service:

  • Session is some information maintained on a server machine with a default life span of 20 minutes after sending the response.
  • It is local for every user.
  • Session along with Web Services are by default disable so to use the session we should enable it for every Web Method.

    Application object with Web Service:

  • It is similar like session maintaining information on server for life span of 5 minutes after sending the response.
  • It is sharable among more than one user.

    Caching with Web Service:

  • Caching is use to maintain some data, output of webpage in a fast accessing temporary memory i.e. caching memory.

Security with Web Services

  1. If the web service placed under UDDI server anybody can access your web services.
  2. So the UDDI server requires registration before access the web services from it. And to provide the communication between UDDI server and application we require passport services.
  3. In .NET 1.1 version the passport services need to install by downloading from http://www.hotmail.com or http://www.ms.com and then we need to specify authentication, authorization settings in application web.config file.
  4. In the Web.Config file
    <authentication mode = “Passport”>
    <Passport redirecturl = “ ”/>
    </authentication>
  5. From .NET 2.0 version onwards passport services are by default integrated and also they are configured on IIS.
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s