Friday, September 16, 2011

asp.net interview questions and answers


When was .NET announced?

Bill Gates delivered a keynote at Forum 2000, held June 22, 2000, outlining the .NET 'vision'. The July 2000 PDC had a number of sessions on .NET technology, and delegates were given CDs containing a pre-release version of the .NET framework/SDK and Visual Studio.NET.

When was the first version of .NET released?

The final version of the 1.0 SDK and runtime was made publicly available around 6pm PST on 15-Jan-2002. At the same time, the final version of Visual Studio.NET was made available to MSDN subscribers.

What platforms does the .NET Framework run on?

The runtime supports Windows XP, Windows 2000, NT4 SP6a and Windows ME/98. Windows 95 is not supported. Some parts of the framework do not work on all platforms - for example, ASP.NET is only supported on Windows XP and Windows 2000. Windows 98/ME cannot be used for development.
IIS is not supported on Windows XP Home Edition, and so cannot be used to host ASP.NET. However, the ASP.NET Web Matrix
web server does run on XP Home.
The Mono project is attempting to implement the .NET framework on Linux.

What is the CLR?

CLR = Common Language Runtime. The CLR is a set of standard resources that (in theory) any .NET program can take advantage of, regardless of programming language. Robert Schmidt (Microsoft) lists the following CLR resources in his MSDN PDC# article:
Object-oriented programming model (inheritance, polymorphism, exception handling, garbage collection)
Security model
Type system
All .NET base classes
Many .NET framework classes
Development, debugging, and profiling tools
Execution and code management
IL-to-native translators and optimizers
What this means is that in the .NET world, different programming languages will be more equal in capability than they have ever been before, although clearly not all languages will support all CLR services.

What is the CTS?

CTS = Common Type System. This is the range of types that the .NET runtime understands, and therefore that .NET applications can use. However note that not all .NET languages will support all the types in the CTS. The CTS is a superset of the CLS.

What is the CLS?

CLS = Common Language Specification. This is a subset of the CTS which all .NET languages are expected to support. The idea is that any program which uses CLS-compliant types can interoperate with any .NET program written in any language.
In theory this allows very tight interop between different .NET languages - for example allowing a C# class to inherit from a VB class.

What is IL?

IL = Intermediate Language. Also known as MSIL (Microsoft Intermediate Language) or CIL (Common Intermediate Language). All .NET source code (of any language) is compiled to IL. The IL is then converted to machine code at the point where the software is installed, or at run-time by a Just-In-Time (JIT) compiler.

What does 'managed' mean in the .NET context?

The term 'managed' is the cause of much confusion. It is used in various places within .NET, meaning slightly different things.Managed code: The .NET framework provides several core run-time services to the programs that run within it - for example
exception handling and security. For these services to work, the code must provide a minimum level of information to the runtime.
Such code is called managed code. All C# and Visual Basic.NET code is managed by default. VS7 C++ code is not managed by default, but the compiler can produce managed code by specifying a command-line switch (/com+).

Managed data: This is data that is allocated and de-allocated by the .NET runtime's garbage collector. C# and VB.NET data is always managed. VS7 C++ data is unmanaged by default, even when using the /com+ switch, but it can be marked as managed using the __gc keyword.

Managed classes: This is usually referred to in the context of Managed Extensions (ME) for C++. When using ME C++, a class can be marked with the __gc keyword. As the name suggests, this means that the memory for instances of the class is managed by the garbage collector, but it also means more than that. The class becomes a fully paid-up member of the .NET community with the benefits and restrictions that brings. An example of a benefit is proper interop with classes written in other languages - for example, a managed C++ class can inherit from a VB class. An example of a restriction is that a managed class can only inherit from one base class.

What is reflection?

All .NET compilers produce metadata about the types defined in the modules they produce. This metadata is packaged along with the module (modules in turn are packaged together in assemblies), and can be accessed by a mechanism called reflection. The System.Reflection namespace contains classes that can be used to interrogate the types for a module/assembly.
Using reflection to access .NET metadata is very similar to using ITypeLib/ITypeInfo to access type library data in COM, and it is used for similar purposes - e.g. determining data type sizes for marshaling data across context/process/machine boundaries.
Reflection can also be used to dynamically invoke methods (see System.Type.InvokeMember ) ,  or even create types dynamically at run-time (see System.Reflection.Emit.TypeBuilder).

What is the difference between Finalize and Dispose (Garbage collection) ?
Class instances often encapsulate control over resources that are not managed by the runtime, such as window handles (HWND), database connections, and so on. Therefore, you should provide both an explicit and an implicit way to free those resources. Provide implicit control by implementing the protected Finalize Method on an object (destructor syntax in C# and the Managed Extensions for C++). The garbage collector calls this method at some point after there are no longer any valid references to the object. In some cases, you might want to provide programmers using an object with the ability to explicitly release these external resources before the garbage collector frees the object. If an external resource is scarce or expensive, better performance can be achieved if the programmer explicitly releases resources when they are no longer being used. To provide explicit control, implement the Dispose method provided by the IDisposable Interface. The consumer of the object should call this method when it is done using the object.
Dispose can be called even if other references to the object are alive. Note that even when you provide explicit control by way of Dispose, you should provide implicit cleanup using the Finalize method. Finalize provides a backup to prevent resources from
permanently leaking if the programmer fails to call Dispose.

What is Partial Assembly References?

Full Assembly reference: A full assembly reference includes the assembly's text name, version, culture, and public key token (if the assembly has a strong name). A full assembly reference is required if you reference any assembly that is part of the common
language runtime or any assembly located in the global assembly cache.

Partial Assembly reference: We can dynamically reference an assembly by providing only partial information, such as specifying only the assembly name. When you specify a partial assembly reference, the runtime looks for the assembly only in the application
directory.
We can make partial references to an assembly in your code one of the following ways:
-> Use a method such as System.Reflection.Assembly.Load and specify only a partial reference. The runtime checks for the assembly in the application directory.
-> Use the System.Reflection.Assembly.LoadWithPartialName method and specify only a partial reference. The runtime checks for the assembly in the application directory and in the global assembly cache

Changes to which portion of version number indicates an incompatible change?
Major or minor. Changes to the major or minor portion of the version number indicate an incompatible change. Under this convention then, version 2.0.0.0 would be considered incompatible with version 1.0.0.0. Examples of an incompatible change would be a change to the types of some method parameters or the removal of a type or method altogether. Build. The Build number is typically used to distinguish between daily builds or smaller compatible releases. Revision. Changes to the revision number are typically reserved for an incremental build needed to fix a particular bug. You'll sometimes hear this referred to as the "emergency bug fix" number in that the revision is what is often changed when a fix to a specific bug is shipped to a customer.



What is side-by-side execution? Can two application one using private assembly and other using Shared assembly be stated as a side-by-side executables?

Side-by-side execution is the ability to run multiple versions of an application or component on the same computer. You can have multiple versions of the common language runtime, and multiple versions of applications and components that use a version of the runtime, on the same computer at the same time. Since versioning is only applied to shared assemblies, and not to private assemblies, two application one using private assembly and one using shared assembly cannot be stated as side-by-side
executables.

Why string are called Immutable data Type ?
The memory representation of string is an Array of Characters, So on re-assigning the new array of Char is formed & the start address is changed . Thus keeping the Old string in Memory for Garbage Collector to be disposed.

What does assert() method do?

In debug compilation, assert takes in a Boolean condition as a parameter, and shows the error dialog if the condition is false. The program proceeds without any interruption if the condition is true.


What's the difference between the Debug class and Trace class?

Documentation looks the same.  Use Debug class for debug builds, use Trace class for both debug and release builds.

Why are there five tracing levels in System.Diagnostics.TraceSwitcher?

The tracing dumps can be quite verbose.  For applications that are constantly running you run the risk of overloading the machine and the hard drive.  Five levels range from None to Verbose, allowing you to fine-tune the tracing activities.

Web Services Interview Questions and answers


What is SOAP?

Simple Object Access Protocol (SOAP) is a lightweight protocol for exchange of information in a decentralized, distributed environment. It's an industry-standard message format that enables message-based communications for Web services.

2. What is UDDI?

Universal Discovery Description and Integration is like the "Yellow Pages" of Web services. A UDDI directory entry is an XML file that describes a business and the services it offers. There are three parts to an entry in the UDDI directory. The "white pages" describe the company offering the service, like, name, address, contacts, etc. The "yellow pages" include industrial categories based on standard taxonomies the Standard Industrial Classification. The "green pages" describe the interface to the service in enough detail for someone to write an application to use the Web service.

3. What is WSDL?

Web Service Description Language (WSDL) defines an XML grammar for describing web services. This description includes details such as where to find the web service (its URL), what methods and properties that service supports, the data types and the protocols used to communicate with the service.

4. Describe Web Service (XML Web Service)?

A Web Service (XML Web Service) is a unit of code that can be activated using HTTP requests. Stated another way, a Web Service is an application component that can be remotely callable using standard Internet Protocols such as HTTP and XML. A major advantage of the Web services architecture is, it allows programs written in different languages on different platforms to communicate with each other in a standards-based way. Simply said, a Web service is a software service exposed on the Web through SOAP, described with a WSDL file and registered in UDDI.

5. Give examples of a Web Service?

o Information sources like stock quotes, weather forecasts, sports scores etc that could easily incorporate into applications
o Services that provide commonly needed functionality for other services. Example, user authentication, usage billing etc
o Services that integrate a business system with other partners

6. What is SOAP Protocol message contains?

A SOAP Protocol message contains four parts:

· An envelope

· Encoding Rules

· RPC representation (Convention)

· Protocol binding (optional)

an envelop that defines a framework for describing what is in a message and how to process it, a set of encoding rules for expressing instances of application-defined data types and a convention for representing remote procedure calls (RPC). In protocol binding, almost all SOAP implementations support it as it's the only standardized protocol for SOAP. The HTTP binding is optional.

How many types of diagrams are there in UML ?

There are nine types of diagrams in UML :-
Use case diagram: They describe "WHAT" of a system rather than "HOW" the system does it.They are used to identify the primary elements and processes that form the system. The primary elements are termed as "actors" and the processes are called "use cases". Use Case diagrams shows "actors" and there "roles".
Class diagram: From the use case diagram we can now go to detail design of system, for which the primary step is class diagram. The best way to identify classes is to consider all "NOUNS" in use cases as classes, "VERBS" as methods of classes, relation between actors can then be used to define relation between classes. The relationship or association between the classes can be either an "is-a" or "has-a" relationship which can easily be identified from use cases.
Object diagram: An object is an instance of a class. Object diagram captures the state of classes in the system and their relationships or associations at a specific point of time.
State diagram: A state diagram, as the name suggests, represents the different states that objects in the system undergo during their life cycle. Object change in response to certain simulation so this simulation effect is captured in state diagram. So basically it has a initial state and final state and events that happen in between them. Whenever you think that some simulations are complicated you can go for this diagram.
Sequence diagram: Sequence diagrams can be used to explore the logic of a complex operation, function, or procedure. They are called sequence diagrams because sequential nature is shown via ordering of messages. First message starts at the top and the last message ends at bottom. The important aspect of a sequence diagram is that it is time-ordered. This means that the exact sequence of the interactions between the objects is represented step by step. Different objects in the sequence diagram interact with each other by passing "messages".
Collaboration diagram: A collaboration diagram groups together the interactions between different objects to fulfill a common purpose.
Activity diagram: Activity diagram is typically used for business process modeling, for modeling the logic captured by a single use case, or for visualizing the detailed logic of a business rule.Complicated process flows in the system are captured in the activity diagram. Similar to a state diagram, an activity diagram also consists of activities, actions, transitions, initial and final states, and guard conditions. But difference is state diagrams are in context of simulation while activity gives detail view of business logic.
Deployment diagram: Deployment diagrams show the hardware for your system, the software that is installed on that hardware, and the middleware used to connect the disparate machines to one another. It shows how the hardware and software work together to run a system. In one line its shows the deployment view of the system.
Component diagram: The component diagram represents the high-level parts that make up the system. From .NET angle point of view they form the "NAMESPACES". This diagram depicts, at a3 1 4 high level, what components form part of the system and how they are interrelated. Its shows the logical grouping of classes or group of other components.

What is UML?

The Unified Modeling Language (UML) is a graphical language for visualizing, specifying, constructing, and documenting the artifacts of a software-intensive system.UML provides blue prints for business process, System function, programming language statements, database schemas and reusable components.

B)Which attribute is used in order that the method can be used as WebService ?

WebMethod attribute has to be specified in order that the method and property can be treated as WebService.

What the different phase/steps of acquiring a proxy object in Webservice ?

The following are the different steps needed to get a proxy object of a webservice at the client side :-
√ Client communicates to UDI node for WebService either through browser or UDDI's public web service.
√ UDII responds with a list of webservice.
√ Every service listed by webservice has a URI pointing to DISCO or WSDL document.
√ After parsing the DISCO document, we follow the URI for the WSDL document related to the webservice which we need.
√ Client then parses the WSDL document and builds a proxy object which can communicate with Webservice.

Which attribute is used in order that the method can be used as WebService ?

WebMethod attribute has to be specified in order that the method and property can be treated as WebService.

What is file extension of Webservices ?

.ASMX is extension for Webservices.

What the different phase/steps of acquiring a proxy object in Webservice?

The following are the different steps needed to get a proxy object of a webservice at the
client side :-

√ Client communicates to UDI node for WebService either through browser or
UDDI's public web service.

√ UDII responds with a list of webservice.

√ Every service listed by webservice has a URI pointing to DISCO or WSDL document.

√ After parsing the DISCO document, we follow the URI for the WSDL document related to the webservice which we need.

√ Client then parses the WSDL document and builds a proxy object which can communicate with Webservice.

What is ObjRef object in remoting ?

All Marshal() methods return ObjRef object.The ObjRef is serializable because it implements the interface ISerializable, and can be marshaled by value. The ObjRef knows about :-

√ location of the remote object
√ host name
√ port number
√ object name.

What is marshalling and what are different kinds of marshalling ?

Marshaling is used when an object is converted so that it can be sent across the network or across application domains.Unmarshaling creates an object from the marshaled data.There are two ways to do marshalling :-

√ Marshal-by-value (MBV) :- In this the object is serialized into the channel, and a copy of the object is created on the other side of the network. The object to marshal is stored into a stream, and the stream is used to build a copy of the object on the other side with the unmarshalling sequence.

√ Marshaling-by-reference (MBR):- Here it creates a proxy on the client that is used to communicate with the remote object. The marshaling sequence of a remote object creates an ObjRef instance that itself can be serialized across the network.

Objects that are derived from “MarshalByRefObject” are always marshaled by reference.All our previous samples have classes inherited from “MarshalByRefObject”

To marshal a remote object the static method RemotingServices.Marshal() is used.

RemotingServices.Marshal() has following overloaded versions:-

public static ObjRef Marshal(MarshalByRefObject obj)
public static ObjRef Marshal(MarshalByRefObject obj, string objUri)
public static ObjRef Marshal(MarshalByRefObject obj, string objUri,Type requestedType)

The first argument obj specifies the object to marshal. The objUri is the path that is stored within the marshaled object reference; it can be used to access the remote object.

The requestedType can be used to pass a different type of the object to the object reference.
This is useful if the client using the remote object shouldn't use the object class but an
interface that the remote object class implements instead. In this scenario the interface is the requestedType that should be used for marshaling.

What is Asynchronous One-Way Calls ?

One-way calls are a different from asynchronous calls from execution angle that the .NET
Framework does not guarantee their execution. In addition, the methods used in this kind
of call cannot have return values or out parameters.One-way calls are defined by using
[OneWay()] attribute in class.




W3School

Introduction to Web Services

Web Services can make your applications Web applications.
Web Services are published, found and used through the Web.

What You Should Already Know

Before you continue you should have a basic understanding of the following:
  • HTML
  • XML
If you want to study these subjects first, find the tutorials on our Home page.

What are Web Services?

  • Web services are application components
  • Web services communicate using open protocols
  • Web services are self-contained and self-describing
  • Web services can be discovered using UDDI
  • Web services can be used by other applications
  • XML is the basis for Web services

How Does it Work?

The basic Web services platform is XML + HTTP.
The HTTP protocol is the most used Internet protocol.
XML provides a language which can be used between different platforms and programming languages and still express complex messages and functions.
Web services platform elements
  • SOAP (Simple Object Access Protocol)
  • UDDI (Universal Description, Discovery and Integration)
  • WSDL (Web Services Description Language)
We will explain these topics later in the tutorial

The Future of Web services

Don't expect too much, too soon.
The Web Services platform is a simple, interoperable, messaging framework. It still misses many important features like security and routing. But, these pieces will come once SOAP becomes more advanced.
Hopefully, Web services can make it much easier for applications to communicate. 

Why Web Services?

A few years ago Web services were not fast enough to be interesting.
Thanks to the major IT development the last few years, most people and companies have broadband connection and use the web more and more.

Interoperability has highest priority.

When all major platforms could access the Web using Web browsers, different platforms could interact. For these platforms to work together, Web applications were developed.
Web applications are simple applications run on the web. These are built around the Web browser standards and can mostly be used by any browser on any platform.

Web services take Web applications to the next level.

Using Web services your application can publish its function or message to the rest of the world.
Web services uses XML to code and decode your data and SOAP to transport it using open protocols.
With Web services your accounting departments Win 2k servers billing system can connect with your IT suppliers UNIX server.

Web services have two types of uses.

Reusable application components
There are things different applications need very often. So why make these over and over again?
Web services can offer application components like currency conversion, weather reports or even language translation as services.
Ideally, there will only be one type of each application component, and anyone can use it in their application.
Connect existing software
Web services help solve the interoperability problem by giving different applications a way to link their data.
Using Web services you can exchange data between different applications and different platforms.

Web Services Platform Elements

Web Services have three basic platform elements.
These are called SOAP, WSDL and UDDI.

What is SOAP?

The basic Web services platform is XML plus HTTP.
  • SOAP stands for Simple Object Access Protocol
  • SOAP is a communication protocol
  • SOAP is for communication between applications
  • 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 will be developed as a W3C standard
Read more about SOAP on our Home page.

What is WSDL?

WSDL is an XML-based language for describing Web services and how to access them.
  • WSDL stands for Web Services Description Language
  • WSDL is written in XML
  • WSDL is an XML document
  • WSDL is used to describe Web services
  • WSDL is also used to locate Web services
  • WSDL is not yet a W3C standard
Read more about WSDL on our Home page.

What is UDDI?

UDDI is a directory service where businesses 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
Read more about UDDI on our Home page.

Web Service Example

Any application can have a Web Service component.
Web Services can be created regardless of programming language.

An example ASP.NET Web Service

In this example we use ASP.NET to create a simple Web Service.
<%@ WebService Language="VBScript" Class="TempConvert" %>
Imports System
Imports System.Web.Services
Public Class TempConvert :Inherits WebService
 Public Function FahrenheitToCelsius
(ByVal Fahrenheit As String) As String
dim fahr
fahr=trim(replace(Fahrenheit,",","."))
if fahr="" or IsNumeric(fahr)=false then return "Error"
return ((((fahr) - 32) / 9) * 5) 
end function
 Public Function CelsiusToFahrenheit
(ByVal Celsius As String) As String
dim cel
cel=trim(replace(Celsius,",","."))
if cel="" or IsNumeric(cel)=false then return "Error"
return ((((cel) * 9) / 5) + 32)
end function
end class
This document is a .asmx file. This is the ASP.NET file extension for XML Web Services.

To run this example you will need a .NET server.
The first line in this document that it is a Web Service, written in VBScript and the class name is "TempConvert":
<%@ WebService Language="VBScript" Class="TempConvert" %>
The next lines imports the namespace "System.Web.Services" from the .NET framework.
Imports System
Imports System.Web.Services
The next line defines that the "TempConvert" class is a WebService class type:
Public Class TempConvert :Inherits WebService
The next step is basic VB programming. This application has two functions. One to convert from Fahrenheit to Celsius, and one to convert from Celsius to Fahrenheit.
The only difference from a normal application is that this function is defined as a "WebMethod".
Use "WebMethod" to mark the functions in your application that you would like to make into web services.
 Public Function FahrenheitToCelsius
(ByVal Fahrenheit As String) As String
  dim fahr
  fahr=trim(replace(Fahrenheit,",","."))
  if fahr="" or IsNumeric(fahr)=false then return "Error"
  return ((((fahr) - 32) / 9) * 5) 
end function
 Public Function CelsiusToFahrenheit
(ByVal Celsius As String) As String
  dim cel
  cel=trim(replace(Celsius,",","."))
  if cel="" or IsNumeric(cel)=false then return "Error"
  return ((((cel) * 9) / 5) + 32)
end function
The last thing to do is to end the class:
end class
If you save this as an .asmx file and publish it on a server with .NET support, you should have your first working Web Service. Like our example Web Service

ASP.NET automates the process

With ASP.NET you do not have to write your own WSDL and SOAP documents.
If you look closer on our example Web Service. You will see that the ASP.NET has automatically created a WSDL and SOAP request.

Web Service Use

Using your example ASP.NET Web Service

In the previous example we created an example Web Service.
The Fahrenheit to Celsius function can be tested here: FahrenheitToCelsius.
The Celsius to Fahrenheit function can be tested here: CelsiusToFahrenheit.

These functions will send you a XML reply.
These tests use HTTP POST and will send a XML response like this:
 
38


Use a form to access a Web Service.
Using a form and HTTP POST, you can put the web service on your site, like this:
Fahrenheit to Celsius:

Celsius to Fahrenheit:



Use a form to access the Web Service.
Here is the code to add the Web Service to a web page:
method="POST"> 
  
    
    
  
  
    
    
  
Fahrenheit to Celsius:
    size="30" name="Fahrenheit">
    value="Submit" class="button">
 
method="POST"> 
  
    
    
  
  
    
    
  
Celsius to Fahrenheit:
    size="30" name="Celsius">
    value="Submit" class="button">

Substitute the www.example.com in the code above with the name of your web site.

You Have Learned Web Services, Now What?

Web Services Summary

This tutorial has taught you how to convert your applications into web-applications.
You have learned how to use XML to send messages between applications.
You have also learned how to export a function (create a web service) from your application.

Now You Know Web Services, What's Next?

The next step is to learn about WSDL and SOAP.
WSDL
WSDL is an XML-based language for describing Web services and how to access them.
WSDL describes a web service, along with the message format and protocol details for the web service.
If you want to learn more about WSDL, please visit our WSDL tutorial.
SOAP
SOAP is a simple XML-based protocol that allows applications to exchange information over HTTP.
Or more simply: SOAP is a protocol for accessing a web service.
If you want to learn more about SOAP, please visit our SOAP tutorial.

WSDL Tutorial

WSDL Tutorial

picture
WSDL (Web Services Description Language) is an XML-based language for describing Web services and how to access them.
Start learning WSDL!

Table of Contents

Introduction to WSDL
This introduction to WSDL explains what WSDL is.

WSDL Documents
This chapter explains the main parts of an WSDL document.

WSDL Ports
This chapter explains the WSDL port interface.

WSDL Binding
This chapter explains the WSDL binding interface.

WSDL and UDDI
This chapter explains how UDDI (Universal Description Discovery and Integration) is integrated with WSDL.

WSDL Syntax
The full WSDL syntax as listed in the W3C note.

WSDL Summary
This chapter contains a recommendation on what subject you should study after the WSDL tutorial.

Introduction to WSDL

WSDL is an XML-based language for describing Web services and how to access them.

What You Should Already Know

Before you continue you should have a basic understanding of the following:
  • XML
  • XML Namespaces
  • XML Schema
If you want to study these subjects first, find the tutorials on our Home page.

What is WSDL?

  • WSDL stands for Web Services Description Language
  • WSDL is written in XML
  • WSDL is an XML document
  • WSDL is used to describe Web services
  • WSDL is also used to locate Web services
  • WSDL is not yet a W3C standard

WSDL Describes Web Services

WSDL stands for Web Services Description Language.
WSDL is a document written in XML. The document describes a Web service. It specifies the location of the service and the operations (or methods) the service exposes.

WSDL Development History at W3C

WSDL 1.1 was submitted as a W3C Note by Ariba, IBM and Microsoft for describing services for the W3C XML Activity on XML Protocols in March 2001.
(a W3C Note is made available by the W3C for discussion only. Publication of a Note by W3C indicates no endorsement by W3C or the W3C Team, or any W3C Members)
The first Working Draft of WSDL 1.2 was released by W3C in July 2002.
Go to our W3C Tutorial to read more about specification status and timeline.

WSDL Documents


A WSDL document is just a simple XML document.
It contains set of definitions to describe a web service.

The WSDL Document Structure

A WSDL document describes a web service using these major elements:
Element
Defines
The operations performed by the web service
The messages used by the web service
The data types used by the web service
The communication protocols used by the web service
The main structure of a WSDL document looks like this:
   definition of types........
 
   definition of a message....
 
   definition of a port.......
 
   definition of a binding....
 
A WSDL document can also contain other elements, like extension elements and a service element that makes it possible to group together the definitions of several web services in one single WSDL document.
For a complete syntax overview go to the chapter WSDL Syntax.

WSDL Ports

The element is the most important WSDL element.
It describes a web service, the operations that can be performed, and the messages that are involved.
The element can be compared to a function library (or a module, or a class) in a traditional programming language.

WSDL Messages

The element defines the data elements of an operation.
Each message can consist of one or more parts. The parts can be compared to the parameters of a function call in a traditional programming language.

WSDL Types

The element defines the data type that are used by the web service.
For maximum platform neutrality, WSDL uses XML Schema syntax to define data types.

WSDL Bindings

The element defines the message format and protocol details for each port.

WSDL Example

This is a simplified fraction of a WSDL document:
   
 
   


  

      

      

  
In this example the element defines "glossaryTerms" as the name of a port, and "getTerm" as the name of an operation.
The "getTerm" operation has an input message called "getTermRequest" and an output message called "getTermResponse".
The elements define the parts of each message and the associated data types.
Compared to traditional programming, glossaryTerms is a function library, "getTerm" is a function with "getTermRequest" as the input parameter and getTermResponse as the return parameter
A WSDL port describes the interfaces (legal operations) exposed by a web service.

WSDL Ports

The element is the most important WSDL element.
It defines a web service, the operations that can be performed, and the messages that are involved.
The port defines the connection point to a web service. It can be compared to a function library (or a module, or a class) in a traditional programming language. Each operation can be compared to a function in a traditional programming language.

Operation Types

The request-response type is the most common operation type, but WSDL defines four types:
Type
Definition
One-way
The operation can receive a message but will not return a response
Request-response
The operation can receive a request and will return a response
Solicit-response
The operation can send a request and will wait for a response
Notification
The operation can send a message but will not wait for a response


One-Way Operation

A one-way operation example:
   
   
   
      
   
In this example the port "glossaryTerms" defines a one-way operation called "setTerm".
The "setTerm" operation allows input of new glossary terms messages using a "newTermValues" message with the input parameters "term" and "value". However, no output is defined for the operation.

Request-Response Operation

A request-response operation example:
   
 
   


  

      

      

  
In this example the port "glossaryTerms" defines a request-response operation called "getTerm".
The "getTerm" operation requires an input message called "getTermRequest" with a parameter called "term", and will return an output message called "getTermResponse" with a parameter called "value".

WSDL Bindings


WSDL bindings defines the message format and protocol details for a web service.

Binding to SOAP

A request-response operation example:
   
 
   


  

      

      

  
transport="http://schemas.xmlsoap.org/soap/http" />
  
    
     soapAction="http://example.com/getTerm"/>
    
      
    
    
      
    
  
The binding element has two attributes - the name attribute and the type attribute.
The name attribute (you can use any name you want) defines the name of the binding, and the type attribute points to the port for the binding, in this case the "glossaryTerms" port.
The soap:binding element has two attributes - the style attribute and the transport attribute.
The style attribute can be "rpc" or "document". In this case we use document. The transport attribute defines the SOAP protocol to use. In this case we use HTTP.
The operation element defines each operation that the port exposes.
For each operation the corresponding SOAP action has to be defined. You must also specify how the input and output are encoded. In this case we use "literal".

WSDL and UDDI

Universal Description, Discovery and Integration (UDDI) is a directory service where businesses can register and search for Web services.

What is UDDI

UDDI is a platform-independent framework for describing services, discovering businesses, and integrating business services by using the Internet.
  • 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

What is UDDI Based On?

UDDI uses World Wide Web Consortium (W3C) and Internet Engineering Task Force (IETF) Internet standards such as XML, HTTP, and DNS protocols.
UDDI uses WSDL to describe interfaces to web services
Additionally, cross platform programming features are addressed by adopting SOAP, known as XML Protocol messaging specifications found at the W3C Web site.

UDDI Benefits

Any industry or businesses of all sizes can benefit from UDDI
Before UDDI, there was no Internet standard for businesses to reach their customers and partners with information about their products and services. Nor was there a method of how to integrate into each other's systems and processes.

Problems the UDDI specification can help to solve:

  • Making it possible to discover the right business from the millions currently online
  • Defining how to enable commerce once the preferred business is discovered
  • Reaching new customers and increasing access to current customers
  • Expanding offerings and extending market reach
  • Solving customer-driven need to remove barriers to allow for rapid participation in the global Internet economy
  • Describing services and business processes programmatically in a single, open, and secure environment

How can UDDI be Used

If the industry published an UDDI standard for flight rate checking and reservation, airlines could register their services into an UDDI directory. Travel agencies could then search the UDDI directory to find the airline's reservation interface. When the interface is found, the travel agency can communicate with the service immediately because it uses a well-defined reservation interface.

Who is Supporting UDDI?

UDDI is a cross-industry effort driven by all major platform and software providers like Dell, Fujitsu, HP, Hitachi, IBM, Intel, Microsoft, Oracle, SAP, and Sun, as well as a large community of marketplace operators, and e-business leaders.
Over 220 companies are members of the UDDI community.

The Full WSDL Syntax

The full WSDL 1.2 syntax as described in the W3C Working Draft is listed below.

     *
     ?
     ?
         ?
         *
    
     *
         ?
         *
    
     *
         ?
         *
             ?
             ?
                 ?
            
             ?
                 ?
            
             *
                 ?
            
        
    
     *
         +
    
     *
         ?
        <-- binding details --> *
         *
             ?
            <-- binding details --> *
             ?
                 ?
                <-- binding details -->
            
             ?
                 ?
                <-- binding details --> *
            
             *
                 ?
                <-- binding details --> *
            
        
    
     *
         ?
         *
             ?
            <-- address details -->
        
    

You Have Learned WSDL, Now What?


WSDL Summary

This tutorial has taught you how to create WSDL documents that describes a web service. It also specifies the location of the service and the operations (or methods) the service exposes.
You have learned how to define the message format and protocol details for a web service.
You have also learned that you can register and search for web services with UDDI.

Now You Know WSDL, What's Next?

The next step is to learn about SOAP and Web Services.
SOAP
SOAP is a simple XML-based protocol that allows applications to exchange information over HTTP.
Or more simply: SOAP is a protocol for accessing a web service.
If you want to learn more about SOAP, please visit our SOAP tutorial.
Web Services
Web services can convert your applications into web-applications.
By using XML, Messages can be sent between applications.
If you want to learn more about web services, please visit our Web Services tutorial

.NET Web Services

Web services are small units of code built to handle a limited task.

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 (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.
You can read more about SOAP in our SOAP tutorial.

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

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.