ASP.NET Web Services interview Questions & Answers

Introduction to Web Service Methods in ASP.NET.
Methods of a class that implement a Web service do not automatically have the ability to receive Web service requests and send back responses, but with Web services created using ASP.NET, it is very simple to add that capability. Apply a WebMethod attribute to public methods. Methods of a Web service class that can be communicated with over the Web are called Web service methods.

Web service methods are a key part of the messaging infrastructure employed by Web services. That is, a client and a Web service communicate using messages, specifically SOAP messages, by default. Clients send a SOAP request to a Web service and a Web service method typically returns a SOAP response. Web services define the type of messages they accept using operations, as defined by Web Services Description Language (WSDL). These operations correlate to each of the Web service methods within a Web service.

Even though each of these Web service methods are defined in ASP.NET using a method of a class, it is important to realize that the data that is eventually communicated over the network must be serialized into XML. As such, it is important to remember that Web services are not a replacement for DCOM, but rather a messaging infrastructure for communicating across platforms using industry standards.


Explain WebMethod Attribute in Asp.Net Web Service.
Attaching the WebMethod attribute to a Public method indicates that you want the method exposed as part of the XML Web service. The WebMethod attribute tells .NET that a particular public method should be exposed as a web-callable method. The WebMethod attribute has six associated properties to document and change the behavior of your web method. They are:

Description
MessageName
EnableSession
CacheDuration
TransactionOption
BufferResponse

The first two properties are used to document a web method, while the others affect its behavior.


What are the web services in ASP.NET?
Introduction to web service
A Web service is a class that allows its methods to be called by methods on other machines via common data formats and protocols, such as XML and HTTP. In .NET, the over-the-network method calls are commonly implemented through the Simple Object Access Protocol (SOAP), an XML-based protocol describing how to mark up requests and responses so that they can be transferred via protocols such as HTTP. Using SOAP, applications represent and transmit data in a standardized XML-based format.

A Web service is a software component stored on one machine that can be accessed by an application (or other software component) on another machine over a network. The machine on which the Web service resides is referred to as a remote machine. The application (i.e., the client) that accesses the Web service sends a method call over a network to the remote machine, which processes the call and returns a response over the network to the application.

Methods in a Web service are invoked through a Remote Procedure Call (RPC). These methods, which are marked with the WebMethod attribute, are often referred to as Web service methods or simply Web methods. Declaring a method with attribute WebMethod makes the method accessible to other classes through RPCs and is known as exposing a Web method.

Web services have important implications for business-to-business (B2B) transactions. They enable businesses to conduct transactions via standardized, widely available Web services rather than relying on proprietary applications. Web services and SOAP are platform and language independent, so companies can collaborate via Web services without worrying about the compatibility of their hardware, software and communications technologies.

Web services are not the best solution for certain performance-intensive applications, because applications that invoke Web services experience network delays. Also, data transfers are typically larger because data is transmitted in text-based XML formats.


What is the use of SOAP (Simple Object Access Protocol) in .Net Web Services?
The Simple Object Access Protocol (SOAP) is a platform-independent protocol that uses XML to make remote procedure calls.

Each request and response is packaged in a SOAP message containing the information that a Web service requires to process the message.



What is the use of SOAP (Simple Object Access Protocol) in .Net Web Services?
The Simple Object Access Protocol (SOAP) is a platform-independent protocol that uses XML to make remote procedure calls.

Each request and response is packaged in a SOAP message containing the information that a Web service requires to process the message.


SOAP supports an extensive set of types like the primitive types, DataSet, DateTime, XmlNode and others. SOAP can also transmit arrays of these types and objects of user-defined types.

When a program invokes a Web method, the request and all relevant information are packaged in a SOAP message and sent to the server on which the Web service resides.

A Web service receives a SOAP message and parses its contents (contained in a SOAP envelope) to determine the method that the client wishes to execute and the method's arguments.

After a Web service parses a SOAP message, the proper method is called and the response is sent back to the client in another SOAP message. The client parses the response to retrieve the result.


Can you use User-Defined Types in Web Services?
It is possible to process user-defined types (also known as custom types) in a Web service. These types can be passed to or returned from Web methods. Web service clients also can use these user-defined types, because the proxy class created for the client contains these type definitions.

Custom types that are sent to or from a Web service are serialized, enabling them to be passed in XML format. This process is referred to as XML serialization.

Classes that are used to specify Web method return types and parameter types must provide a public default or parameterless constructor. Properties and instance variables that should be serialized in XML format must be declared public. Properties that should be serialized must provide both get and set accessors. Read-only properties are not serialized. Data that is not serialized simply receives its default value when an object of the class is deserialized.


What is WSDL?
WSDL (Web Services Description Language) is an XML-based language for describing Web services and how to access them. It 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.


About WSDL (Web Services Description Language)

* 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
* It possible to group together the definitions of several web services in one single WSDL document.

According to W3C
As communications protocols and message formats are standardized in the web community, it becomes increasingly possible and important to be able to describe the communications in some structured way. WSDL addresses this need by defining an XML grammar for describing network services as collections of communication endpoints capable of exchanging messages. WSDL service definitions provide documentation for distributed systems and serve as a recipe for automating the details involved in applications communication.


What is UDDI?
The Universal Description, Discovery and Integration (UDDI) protocol is one of the major building blocks required for successful Web services. UDDI creates a standard interoperable platform that enables companies and applications to quickly, easily, and dynamically find and use Web services over the Internet. UDDI is a cross-industry effort driven by major platform and software providers, as well as marketplace operators and e-business leaders. To find web services you can visit http://www.uddi.org.


UDDI is an important enabling element of the service-oriented approach to software design. The standard specifies protocols for accessing a registry for Web services, methods for controlling access to the registry, and a mechanism for distributing or delegating records to other registries. In short, a UDDI registry provides a standards based approach to locate a software service, to invoke that service, and to manage metadata about that service.

The UDDI project takes advantage of Worldwide Web Consortium (W3C) and Internet Engineering Task Force (IETF) standards such as Extensible Markup Language (XML), and HTTP and Domain Name System (DNS) protocols. Additionally, cross platform programming features are addressed by adopting early versions of the proposed Simple Object Access Protocol (SOAP) known as XML Protocol messaging specifications found at the W3C Web site. The UDDI protocol is the building block that will enable businesses to quickly, easily and dynamically find and transact with one another using their preferred applications.


What are the benefits of UDDI?

# Service consumers can use UDDI to discover services that suit their requirements and to obtain the service metadata needed to consume those services.
# Service providers can use UDDI to advertise the services they offer.
# Helps lower the total cost of ownership (TCO) of IT resources.
# Contributes to more reliable and manageable applications.
# IT administrators can catalog and manage the programmable resources in their network.


How do people use UDDI?
A business may deploy one or more private and/or public UDDI registries. A private registry permits access to only authorized users. A public registry does not restrict access to the registry. A business may choose to deploy multiple registries in order to segregate internal and external service information. An internal registry supports intranet applications, while an external registry supports extranet applications. Industry groups may deploy a UDDI registry to support public or private exchanges.


What is the UDDI Business Registry (UBR)?
The UDDI Business Registry (UBR) is a free, public UDDI registry currently jointly operated by IBM, Microsoft, NTT Communications, and SAP. Anyone is free to publish information to any of the UBR nodes and to query any of these.

In short, a UDDI registry provides a standards based approach to locate a software service, to invoke that service, and to manage metadata about that service.

4 comments:

Thiep said...

First of all. Thanks very much for your useful post.

I just came across your blog and wanted to drop you a note telling you how impressed I was with the information you have posted here.

Please let me introduce you some info related to this post and I hope that it is useful for community.

Source: google interview questions

Thanks again
Ngo

Abhinay said...

Thank you for posting!!!
The way you described was Awesome!!!

Tech Shankar said...

Welcome Dear Dudes : Abhinay and Thiep

Nikey said...

Really a nice collection of web service questions and a complete answers I ever found on internet.
Thanks a lot.