Tuesday, February 2, 2010

Web Services Interview Questions


What platforms do .NET XML Web Services run on? 
Currently, they're supported on Windows 2000 and Windows XP. ASP.NET integrates with Internet Information Server (IIS) and thus requires that IIS be installed. It runs on server and non-server editions of Windows 2000 and XP as long as IIS is  
installed.  

Can two different programming languages be mixed in a single ASMX file? 
No.  

What is code-behind? 
Code-behind allows you to associate Web Service source code written in a CLR compliant language (such as C# or VB.NET) as compiled in a separate file (typically *.asmx.cs or *.asmx.vb). You would otherwise typically find the executable  code directly inserted into the .asmx file.  

What namespaces are imported by default in ASMX files? 
The following namespaces are imported by default. Other namespaces must be imported manually.· System, System.Collections,System.ComponentModel,System.Data, System.Diagnostics,System.Web,System.Web.Services  

How do I provide information to the Web Service when the information is required as a SOAP Header? 
The key here is the Web Service proxy you created using wsdl.exe or through Visual Studio .NET's Add Web Reference menu option. If you happen to download a WSDL file for a Web Service that requires a SOAP header, .NET will create a SoapHeader class in the proxy source file. Using the previous example:    
      public class Service1 : System.Web.Services.Protocols.SoapHttpClientProtocol
        {   
            public AuthToken AuthTokenValue;       
       
        [System.Xml.Serialization.XmlRootAttribute(Namespace="http://tempuri.org/", IsNullable=false)]       
            public class AuthToken : SoapHeader {        public string Token;    }}  
    
In this case, when you create an instance of the proxy in your main application file, you'll also create an instance of the AuthToken class and assign the string:     
     Service1 objSvc = new Service1();
     processingobjSvc.AuthTokenValue = new AuthToken();
     objSvc.AuthTokenValue.Token = ;
     Web Servicestring strResult = objSvc.MyBillableWebMethod();  
    
What is WSDL?
WSDL is the Web Service Description Language, and it is implemented as a specific XML vocabulary. While it's very much more complex than what can be described here, there are two important aspects to WSDL with which you should be aware. First, WSDL provides instructions to consumers of Web Services to describe the layout and contents of the SOAP packets  the Web Service intends to issue. It's an interface description document, of sorts. And second, it isn't intended that you  read and interpret the WSDL. Rather, WSDL should be processed by machine, typically to generate proxy source code (.NET) or create dynamic proxies on the fly (the SOAP Toolkit or Web Service Behavior).  


Remoting FAQ's



What distributed process frameworks outside .NET do you know? 
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).

What are possible implementations of distributed applications in .NET? 
 .NET Remoting and ASP.NET Web Services. If we talk about the Framework Class Library, noteworthy classes are in  System.Runtime.Remoting and System.Web.Services.

When would you use .NET Remoting and when Web services?
Use remoting for more efficient exchange of information when you control both ends of the application. Use Web services for     open-protocol-based information exchange when you are just a client or a server with the other end belonging to someone else.

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.

What are 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 deep 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.

What are channels in .NET Remoting? 
Channels represent the objects that transfer the other serialized objects from one application domain to another and from  one computer to another, as well as one process to another on the same box. A channel must exist before an object can be transferred.
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.

What is a formatter?
 A formatter is an object that is responsible for encoding and serializing data into messages on one end, and deserializing  and decoding messages into data on the other end.

Choosing between HTTP and TCP for protocols and Binary and SOAP for formatters, what are the trade-offs? 
Binary over TCP is the most effiecient, SOAP over HTTP is the most interoperable.

What's SingleCall activation mode used for? 
If the server object is instantiated for responding to just one single request, the request should be made in SingleCall mode.

What's Singleton activation mode? 
A single object is instantiated regardless of the number of clients accessing it. Lifetime of this object is determined by  lifetime lease.

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

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 can you automatically generate interface for the remotable object in .NET with Microsoft tools?
Use the Soapsuds tool.   

No comments:

Post a Comment