Sunday, February 15, 2009

asp .net : Remote and Web service Interview questions

Que:- What is .NET Remoting ?
Ans:- .NET remoting is replacement of DCOM. Using .NET remoting you can make remote
object calls which lie in different Application Domains. As the remote objects run in
different process client calling the remote object can not call it directly. So the client uses
a proxy which looks like a real object.

When client wants to make method call on the remote object it uses proxy for it. These
method calls are called as “Messages”. Messages are serialized using “formatter” class
and sent to client “channel”. Client Channel communicates with Server Channel. Server
Channel uses as formatter to deserialize the message and sends to the remote object.


Que:- Which class does the remote object has to inherit ?
Ans:- All remote objects should inherit from System.MarshalbyRefObject.


Que:- What are two different types of remote object creation mode in .NET ?
Ans:- There are two different ways in which object can be created using Remoting :-
SAO (Server Activated Objects) also called as Well-Known call mode.
CAO (Client Activated Objects)

SAO has two modes “Single Call” and “Singleton”. With Single Call object the object is
created with every method call thus making the object stateless. With Singleton the object
is created only once and the object is shared with all clients.

CAO are stateful as compared to SAO. In CAO the creation request is sent from client
side. Client holds a proxy to the server object created on server.

Que:- Describe in detail Basic of SAO architecture of Remoting?
Ans:-
Remoting has at least three sections :-
* Common Interface which will be shared between them.
* Server.
* Client.

Que:- What are the situations you will use singleton architecture in remoting ?
Ans:- If all remoting clients have to share the same data singleton architecture will be used.

Que:- What are the ways in which client can create object on server in CAO model ?
Ans:- There are two ways by which you can create Client objects on remoting server :
Activator.CreateInstance().
By Keyword “New”

Que:- How can we call methods in remoting Asynchronously ?
Ans:- All previous examples are a synchronous method calls that means client has to wait until
the method completes the process. By using Delegates we can make Asynchronous method
calls.

Que:- What is Asynchronous One-Way Calls ?
Ans:- 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.

Que:- What is marshalling and what are different kinds of marshalling ?
Ans:- 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.

Que:- What is ObjRef object in remoting ?
Ans:- 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

MOST IMPORTANT QUESTION

Que:- What is a Web Service ?
Ans:- Web Services are business logic components which provide functionality via the Internet
using standard protocols such as HTTP.
Web Services uses Simple Object Access Protocol (SOAP) in order to expose the business
functionality.SOAP defines a standardized format in XML which can be exchanged
between two entities over standard protocols such as HTTP. SOAP is platform independent
so the consumer of a Web Service is therefore completely shielded from any
implementation details about the platform exposing the Web Service. For the consumer it
is simply a black box of send and receive XML over HTTP. So any web service hosted on
windows can also be consumed by UNIX and LINUX platform.

Que:- What is UDDI ?
Ans:- Full form of UDDI is Universal Description, Discovery and Integration. It is a directory
that can be used to publish and discover public Web Services. If you want to see more
details you can visit the http://www.UDDI.org .


Que:- What is DISCO ?
Ans:- DISCO is the abbreviated form of Discovery. It is basically used to club or group common
services together on a server and provides links to the schema documents of the services
it describes may require.

Que:- What is WSDL?
Ans:- Web Service Description Language (WSDL)is a W3C specification which defines XML
grammar for describing Web Services.XML grammar describes details such as:-
* Where we can find the Web Service (its URI)?
* What are the methods and properties that service supports?
* Data type support.
* Supported protocols

In short its a bible of what the webservice can do.Clients can consume this WSDL and
build proxy objects that clients use to communicate with the Web Services. Full WSDL
specification is available at http://www.w3.org/TR/wsdl.

Que:- What is file extension of Webservices ?
Ans:- .ASMX is extension for Webservices.

Que:-Which attribute is used in order that the method can be used as WebService?
Ans:- WebMethod attribute has to be specified in order that the method and property can be
treated as WebService.

Que:- Do webservice have state ?
Twist :- How can we maintain State in Webservices ?
Ans:-

Webservices as such do not have any mechanism by which they can maintain state.
Webservices can access ASP.NET intrinsic objects like Session, application and so on if
they inherit from “WebService” base class.


Imports System.Web.Services
Public class TestWebServiceClass
Inherits WebService
Public Sub SetSession(value As String)
session("Val") = Value
End Sub
end class

Above is a sample code which sets as session object called as “val”. TestWebserviceClass
is inheriting from WebService to access the session and application objects.

1 comment:

Unknown said...

Thank you for providing the interview questions. i am really happy... can you provide more and more...