Tuesday, November 30, 2010

Interview Questions on Remoting/Web Services

What are the properties of a [WebMethod ] attribute?
1. Description
2. MessageName
3. EnableSession
4. CacheDuration
5. TransactionOption
6. BufferResponse

Name the layers of the WebServices protocol stack?
Layer 1 --> Transport Layer (HTTP, SMTP,FTP)
Layer 2 --> XML Messaging Layer (XML,SOAP)
Layer 3 --> WSDL Layer
Layer 4 --> UDDI Layer

Is overloading possible in web services?
Yes, We can overload webmethods in a webservice.

There is the MessageName property of a WebMethod attribute! The MessageName property enables the XML Web Service to uniquely identify overloaded methods using an alias. The default value of this property is the method name, but you can change it to distinguish this overloaded method
implementation from others. When specifying the method name, the resulting SOAP messages will reflect this name instead of an actual method name.

What security measures exist for .NET Remoting in System.Runtime.Remoting?
None. Security should be taken care of at the application level. Cryptography and other security techniques can be applied at application or server level.

Can you configure a .NET Remoting object via XML file?
Yes, via machine.config and application level .config file (or web.config in ASP.NET). Application-level XML settings take precedence over machine.config.

How do you define the lease of the object?
By implementing ILease interface when writing the class code.

How can you automatically generate interface for the remotable object in .NET with Microsoft tools?
Use the Soapsuds tool.

What’s a proxy of the server object in .NET Remoting?
It’s a fake copy of the server object that resides on the client side and behaves as if it was the server. It handles the communication between real server object and the client object. This process is also known as marshaling.

Explain what relationship is between a Process, Application Domain, and Application?
A process is an instance of a running application. An application is an executable on the hard drive or network. There can be numerous processes launched of the same application (5 copies of Word running), but 1 process can run just 1 application.

Name the distributed systems available apart from .Net Remoting.
Distributed Computing Environment/Remote Procedure Calls (DEC/RPC),
Microsoft Distributed Component Object Model (DCOM),
Common Object Request Broker Architecture (CORBA), and
Java Remote Method Invocation (RMI).

Define remotable objects in .NET Remoting.
Remotable objects are the objects that can be marshaled across the application domains.You can marshal by value, where a copy of the object is created and then passed to the receiver. You can also marshal by reference, where just a reference to an existing object is passed.

Advantage of Remoting over Web Services.

.Net Remoting can work with both internet and interanet.
WebService Support only SOAP/HTTP while .Net Remoting support TCP/HTTP.
.Net Remoting best for interanet while web service best for inernet.
.Net Remoting best for homogeneous platform while Web Services best for hetrogeneous platform.
TCP is fast than HTTP.
.Net type system and can expose any object to the client. .Net Web Service supports on those types that can be expressed with XSD.
When to use .Net Remoting over Web services
.Net Remoting provides distributed solution for a corporate use. So, if you need distributed environment to be implemented for internal use, .Net remoting is the best choice. If you require a faster distributed solution, .Net Remoting with TCP protocol using binary format is faster than Web services. .Net Remoting is better solution when large transfer of data is required. Web Services are best when you need to communicate with an external organization or non .NET technology.

What is an application domain?
Previously "PROCESS" were used as security boundaries. One process has its own virtual memory and does not over lap the other process virtual memory; Due to this one process can not crash the other process. So any problem or error in one process does not affect the other process. In .NET they went one step ahead introducing application domains. In application domains multiple applications can run in same process with out influencing each other. If one of the application domains throws error it does not affect the other application domains. To invoke method in a object running in different application domain .NET remoting is used.

What are two different types of remote object creation mode in .NET?
There are two different ways in which object can be created using Remoting:

o SAO (Server Activated Objects) also called as Well-Known call mode.
o 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. It is stateful for client bases.

What is fundamental of published or precreated objects in Remoting?
In scenarios of singleton or single call the objects are created dynamically. But in situations where you want to precreate object and publish it you will use published object scenarios.

Dim obj as new objRemote
obj.Initvalue = 100
As shown in above sample following changes will be needed on server side.
RemotingConfiguration.RegisterWellKnownServiceType is replaced by RemotingServices.Marshal(obj,"RemoteObject") where "obj" is the precreated object on the server whose value is initialized to 100

What are the ways in which client can create object on server in CAO model?
There are two ways by which you can create Client objects on remoting server :
By Keyword "New".

And Singleton and SingleCall
"RemoteObject", WellKnownObjectMode.Singleton)

Can Non-Default constructors be used with Single Call SAO?
Non-Default constructors can not be used with single call objects as object is created with every method call, there is no way to define Non-default constructors in method calls. It’s possible to use Non-Default constructor with Client activated objects as both methods "NEW" keyword and "Activator.CreateInstance()" provide a way to specify Non-Default constructors.

What is Asynchronous One-Way Calls?
One-way calls are a different from asynchronous calls from execution angle.In one way call .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.

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.

What is UDDI?
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 .

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 and object name.

What is DISCO?
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.

What happens when a client activates a remote object?
When a client activates a remote object, it receives a proxy to the remote object. All operations on this proxy are appropriately indirected to enable the remoting infrastructure to intercept and forward the calls appropriately.

What is considered as Remote Object?
Any object outside the application domain of the calling application is considered remote object, even if the objects are executing on the same machine.

Can you treat every object as a remote object?
Objects that cannot be serialized cannot be passed to a different application domain and are therefore nonremotable.

What are the ways in which an object can be serialized?
1. Mark your class with serializable attribute.
2. Make your class implement ISerializable interface.

1 comment:

Dakota said...


I like this post:

You create good material for community.

Please keep posting.

Let me introduce other material that may be good for net community.

Source: Web interview questions

Best rgs