Thursday, September 20, 2012

ASP.NET Web Services interview Questions & Answers


http://vijaybalajithecitizen.blogspot.in/2008/11/aspnet-web-services-interview-questions.html

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.




Q.What is a "Web Service"?
A.A "Web Service" is a .NET component that replies to HTTP requests that are formatted using SOAP syntax.
 Web services are one of the cornerstones of the .NET initiative in that they allow a degree of interoperability among applications over the internet that was inconceivable before.
top ^
Q.How are web services implemented in .NET?
A.Web services are implemented as HTTP Handlers that intercept requests to .asmx files.
top ^
Q.What are the drawbacks of "Response Caching"?
A.
  • If the method or accepts a wide range of values, response caching might be inefficient or even wasteful because a great deal of information might be stored in caching.
  • If the method depends on other information not supplied in parameters (like user authentication or session data), it will be bypassed.
  • The method will be bypassed even if it needs to perform actions other than returning values (like writing to a log file)
top ^
Q.How to overcome the limitations of response caching while providing an acceptable level of caching?
A.By using data caching (System.Web.Caching.Cach)
top ^
Q.What are the protocols supported by web services built with ASP.NET to exchange data?
A.
  • HTTP GET
  • HTTP POST
  • SOAP
top ^
Q.What are the limitations of using GET & POST to communicate with a web service?
A.
  • It is less secured than SOAP.
  • It prevents the user from passing structures and objects as arguments
  • It prevents the user from passing ByRef arguments
top ^
Q.How to make a class accessible as a web service?
A.
  • By making the class inherits from the System.Web.Services.WebService class
  • By qualifying the class with the WebService attribute
 Inheriting from the WebService class is beneficiary in that it allows the class to access the ASP.NET context and other useful objects such as the session and application objects. On the other hand, qualifying the class with the WebService attribute allows for setting additional properties of the web service such as its description and namespace.
 
C# [WebService] public class TestService : System.Web.Services.WebService
VB <WebService> _ Public Class TestService Inherits System.Web.Services.WebService
top ^
Q.How to make a method of a web service class accessible through the internet?
A.By qualifying the method with the WebMethod attribute.
 
C# [WebMethod()] public string MethodName()
VB <WebMethod()> _ Public Function MethodName() As String

No comments:

Post a Comment