Web Services, Remoting Interview Questions and Answers (102) - Page 2

Describe the type of remotable objects in .Net Remoting.

Marshal-by-value-objects - When client calls a method on marshal-by-value-object, the remoting system creates a copy of this object and passes the copy to the client application domain. The copy hence received can handle any method call in client domain. Using Marshal-by-value-object reduces resource consuming trip across network.
Marshal-by-reference-object - When client calls a method on Marshal by reference object, the remoting system create proxy object in the caller application that contains the reference of all method and properties of the object.
What are the remotable and non-remotable objects in .Net Remoting.

The remotable objects are the objects which can be distributed accross domains, can be used with domain. The non-remotable objects are the objects which can't be distributed accross domains. In distributed system, if an object is very big, we can make it non-remotable object.
What is the difference between well-formed and valid XML document?

W3C, in the XML specification, has defined certain rules that need to be followed while creating XML documents. The examples of such rules include: having exactly one root element, having end-tag for each start- tag, using single/double quotes for attribute values, and so on. If an XML document follows all these rules, it is said to be well-formed document and XML parsers can be used to parse and process such documents.
Document Type Definitions (DTDs) or XML Schemas can be used to define the structure and content of a specific class of XML documents. This includes the parent-child relationship details, attribute lists, data type information, value restrictions, etc. In addition to the well-formedness rules, if an XML document also follows the rules specified in the associated DTD/Schema, it is said to be a valid XML document. All valid XML documents are well-formed; but the reverse is not always true, that is, well-formed XML documents do not necessarily have to be valid.
Describe the term Channel in .Net Remoting

In .Net Remoting, an application use Channel to send message to another application which is running in different domain or process. Before sending message, Channel converts message into appropriate format like XML or binary format. The channel that carries message(Mashalled parameter) can use protocal like TCP and HTTP. Channel can be HTTPChannel and TCPChannel. The HTTPChannel use soapFormatter to serialize messages into the XML format using SOAP protocal. Using SOAP method allows the client to call method on the remote object that might not be using .Net framework. The TCPChannel use binaryFormatter to serialize message into binary stream.
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.
How to Create And Delploy A WebService Using C#

First, let's start off by creating a very simple webservice.
Creating A Webservice
1.Create a folder named Webservice under wwwroot
2. Create a File
<%@ WebService Language="c#" Class="AddNumbers"%>

using System;
using System.Web.Services;
public class AddNumbers : WebService
public int Add(int a, int b){
int sum;
sum = a + b;
return sum;
3.Save this file as AddService.asmx [asmx-> file extension]
4.Now the webservice is created and ready for the clients to use it.
5. Now we can call this webservice using
http://ip address/Webservice/Addservice.asmx/Add?a=10&b=5
This will return the result in XML format
Deploying the Webservice in the Client Machine
1.At the command prompt:
WSDL http://ip address ofthe site/WebService/MathService.asmx /n:NameSp /out:FileName.cs]
-This will create a file called FileNmame.cs .
WSDL -> WebServices Description Language (This is an application available at C:\Program
NameSp -> Name of the NameSpace which will be used in client code for deploying the webservice.
CSC /t:library /r:system.web.dll /r:system.xml.dll CreatedFile.cs
This will create a dll with the name of the public class of the asmx file.( In our case, it is "AddNumbers.dll" )
CSC is an application available at C:\WINNT\Microsoft.NET\Framework\v1.0.2914
3.Put the dll file inside WWWRooT\BIN [Create a BIN Folder in WWWRoot]
Making use of WebService in client asp/aspx page
<%@ import Namespace = "NameSp" %>
<script language = "c#" runat = "server">
public void Page_Load(object o, EventArgs e){
int x = 10;
int y = 5;
int sum;
//Instantiating the public class of the webservice
AddNumbers AN = new AddNumbers();
sum = AN.Add(x,y);
string str = sum.ToString();
It is advisable to
1. Copy the .asmx file to the folder containing WSDL aplication (C:\Program Files\Microsoft.NET\FrameworkSDK\Bin) before creating cs file.
2. Copy the created .cs file to the folder containing CSC application
What is Remoting?

The process of communication between different operating system processes, regardless of whether they are on the same computer. The .NET remoting system is an architecture designed to simplify communication between objects living in different application domains, whether on the same computer or not, and between different contexts, whether in the same application domain or not.
What is singleton?

Singleton types never have more than one instance at any one time. If an instance exists, all client requests are serviced by that instance.
What is singlecall?

Single Call types always have one instance per client request. The next method invocation will be serviced by a different server instance, even if the previous instance has not yet been recycled by the system.
What are the facilities available in .NET to deal with XML.

The main classes working with XML data are as follows: -

1. XmlTextReader 

2. XMLTextWriter
3. XMLDocument
4. XmlDataDocument
5. XmlNodeReader
6. DocumentNavigator

Difference between XMLDoc and XMLReader?

We use XMLTextReader to read XML streams.XMLdocument can be used to edit and navigate the document

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.
Webservices are created with the following two files

NOTE: This is objective type question, Please click question title for correct answer.
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
In XML What is CDATA Attribute?

All text in an XML document will be parsed by the parser. But text inside a CDATA section will be ignored by the parser.

Everything inside a CDATA section is ignored by the parser. A CDATA section starts with "<![CDATA[" and ends with "]]>":


function matchwo(a,b)
if (a < b && a < 0) then
return 1;
return 0;

In the example above, everything inside the CDATA section is ignored by the parser.

Notes on CDATA sections:

A CDATA section cannot contain the string "]]>". Nested CDATA sections are not allowed.

The "]]>" that marks the end of the CDATA section cannot contain spaces or line breaks.
What is UDDI?

UDDI Stands fot Universal Description Discovery and Integration. It helps in registering the services provided by the service providers so that they can be shared. It also helps the service consumers or web users in locating the web services.
Define XSLT and XPATH?

XSLT language is used for transforming XML documents into XHTML documents. It also transforms XML into another XML document.

XPATH is a language that is used to navigate through XML documents. It can find information in an XML document like elements and attributes etc.
Define XMLReader Class and XMLValidatingReader class?

The XMLReader Class (Assembly: System.Xml.dll) represents a reader that provides fast, non-cached, forward-only access to XML data.

The XMLValidatingReader class (Assembly: System.Xml.dll) represents a reader that provides:
a) Document type definition (DTD),
b) XML-Data Reduced (XDR) schema, and
c) XML Schema definition language (XSD) validation
Found this useful, bookmark this page to the blog or social networking websites. Page copy protected against web site content infringement by Copyscape

 Interview Questions and Answers Categories