.Net and Web Services: A how to do document
Assembly is nothing but .DLLs or .EXEs. An assembly can contain more then one file.
An assembly also includes Metadata a
Metadata is same as IDL (Interface definition Language which is used by COM)
Metadata describes about Classes, Interfaces Methods, and types of Assembly.
Every Assembly contains Manifest, which describes Assembly itself like Assembly
, Authors and External Assembly references.
Assembly is produced when we compile the .NET language Source code, this code is
also called Managed code. When we compile Source code the .NET compilers will
produce MSIL code (Microsoft Intermediate Language)
or simply IL. MSIL is not
specific to any processor. This is the same as JAVA byte code. When we execute this
program this MSIL code gets compiled again using JIT (Just in Time compilation) to
PE (portable executable) or Native code (which machine it is r
This technique groups related types into namespaces so they can be searched and
referenced more easily.
Every class that you create in Visual C#.NET belongs to a namespace. Usually, your
classes belong to a namespace that has the
same name as your project (which is
also the name given by default to the assembly that will contain your classes).
However, you can change the project
wide namespace used for all of your classes by
using the Project Properties
em; // Here is a system is namespace
// this is my own namespaces this contains some functions and Methods.
Public class Ragavan
Public void Main ()
Console.WriteLine (“welcome to Sreeni.NET world”);
// console method is there in System Namespace.
Namespaces provide a hierarchical way of organizing class names to avoid "name
pollution." That's all they do
they have nothing to do with inheritance or
Web service is
simply an application that exposes a Web
accessible API. That means
you can invoke this application programmatically over the Web. Using SOAP Protocol
XML+HTTP =SOAP (Simple Object Access protocol)
Web services allow applications to share data.
services can be called across platforms and operating systems regardless of
.NET is Microsoft's platform for XML Web services.
Using SOAP you can invoke the WebSerices. (HTTP
Simple Object Access prot
ocol is message
based protocol. Based on Request
and Response. Here I am not going to explain more details about
Web Service Application:
Like Pay per view Channel we can make Software as pay per use, using Web service.
For example, let say
developed Expensive Software for 3D Virtual
Modeling. Lot of company does not want acquire the licensee because it is expensive
and they need to pay for Support etc… instead of this if Infovision makes this
software as a WebService, most of t
he company will use as pay per use.
Another example Credit card validation we can expose as a webservice. (Good
example for webService)
Using VisualStudio.NET we can easily create WebServices. ASP.NET WebService this
project type will be used to creat
Web Services Architecture
Creating a WebService Using VisualStudio.NET
we read about
. NET Framework and WebServices
we are going to learn how to create a WebService using VS.NET (using
Consume the Webservice from VB.NET Client. This Article is based on VS.NET RC1
Launch VS.NET IDE and create a new project
New project Dialog Box will open and
Project Type as a
Visual Basic projects
and Templates as
as shown below.
Then click “
” . This will create a virtual directory under Default web site (IIS).
double click that will take you to the
window. As shown
below. WebService will have.
In this code window we can add a method (Webmethod) that exposes to call over
this type of method call
is very important. This will allow method to invoke over the
Web using SOAP.
First we need to specify a
Attribute and the Function or Sub name
<WebMethod ()> Public Function Add (Num1 as in
teger, Num2 as integer) as
In the code window edit
Web methods as shown above, and then buil
(compile) the project. If compiling successfully, view
in Browser. This
methods. (Using HTTP
GET). This is generated by VS.NET
Enter the num1 and num2 values click
this will invoke Add method in
Service1.asmx using HTTP
GET (this is different from calling a method through SOAP ).
GET we tested the
webservice. This default Interface, which
provided by VS.NET. Next we will see how to consume this same service using SOAP.
The following CODE SNIPPET gives the information about
Consuming the WebService from VB.NET Client
First create a new VB.NET Console Application project.
Construct a SOAP Request Message as Shown below
Every SOAP message has
Envelope, Header, and Body.
The above SOAP Request
Message posted to
corresponding SOAP Response message is show below with Result.
Method SOAP Request Message is posted to the Web Server.
SOAP Response Mes
sage as a result.
In this article we understand how to Create and test Web Service Using
VisualStudio.NET. You are welcome to contact me through
with your comments or questions
A WebMethod represents a Web method. WebMethod has 6 properties they are
WebMethod Example in VB.NET
<WebMethod ()> public Function SayHello ()
Return "Hello Ragavan"
This Attribute tells that this
exposable over the
. This type of method called
Example in C#
Public string SayHello ()
return "Hello Ragavan";
utes have a Description Property.
With this property we can associate documentation with our web Service and
For example you can use Description Attribute to describe the Webmethod.
[WebMethod (Description="This method will add three intege
Public int Add (int a, int b, int c)
This property useful when we want overloading the WebMethods.
"Hi" & " " & sN
This Property used for to enable the session in WebServices.
(Remember WebServiecs uses HTTP protocol th
is is stateless) .if we want to
maintain the state between client and server we need to use this property. Default
Public string SayHiToMS ()
return " Hello to .NET ";
cache the previously accessed result. Next time the same user or different
user asks we can
from cache. Here result cached 60 milliseconds. if we
invoke this method with in 60 milliseconds it will print same time . This will increase
the Web Servi
TransactionOption Can be one of five modes:
en though there are five modes, web methods can only participate as the root
object in a transaction. This means both Required and RequiresNew result in a new
transaction being created for the web method. The Disabled, NotSupported, and
result in no transaction being used for the web method. The
TransactionOption property of a web method is set to Disabled by default.
(boolean) Controls whether or not to buffer the method's response
Invoke single method on a stateless object
Invoke multiple methods on a stateful object
Have all clients invoke methods on the same
Pass through firewalls
Uses HTTP for communication
es raw TCP socket for communication
Use IIS as host
Allow custom host
compliant formatting of data
Uses smaller binary formatting of data
Retrieve partial copy of data from complex object
Retrieve complete c
opy of complex object