1.You are creating a client Application that will reference a Web Service.The Web Service resides in a remote server.You plan to use the remoting frame Work

Which tool should you use to obtain metadata about the remote server object that you can use to create a proxy for the server object?

a)Disco.exe
b)Soapsuds.exe
c)Wsdl.exe
d)Tlbexp.exe

Answer : b (Soapsuds.exe)

Explanation :

You should use Soapsuds.exe, which is the Soapsuds tool. You use Soapsuds to extract type information about the service from a Web Services Description Language(WSDL) file and to convert they type information needed by .NET. You can use the outputassemblyfile(-oa) parameter for Soapsouds to create an assembly file that contains a proxy for the Web Service.

You should not use Disco.exe, which is the Web Services Discovery Tool. You can use Disco.exe to search for discovery documents and to create local copies of these documents. Discovery Documents include files with the .disco extension as well as files with extensions such as .wsdl,.xsd,.discomap and .vsdisco.

You should not use Wsdl.exe, which is the Web Services Description Language tool. You can use Wsdl.exe to create WSDL files as well as to create proxy code based on the information in WSDL File.

You should not use Tlbexp.exe, which is the Type Library Export Tool. You can use Tlbexp.exe to create a type library that contains descriptions of the types defined in an assembly



2.You are part of a team that is developing a Web Service in Visual Studio.You are examining some of your worker's code, and you find the following lines:

Code:

XmlTextReader TxtRead=new XmlTextReader("BookList.xml");
XmlValidatingReader ValidateRead=new XmlValidatingReader(TxtRead);
ValidateRead.ValidationType=ValidationType.DTD;
ValidateRead.ValidationEventHandler+=new ValidationEventHandler(ValidationHandler);
While(ValidateRead.Read());

What do these lines of code do?

a)Create a XML File named BookList.xml Based on external document type definition file.
b)Validate the XML File BookList.xml against a Document Type Definition file.
c)Read the XML file BookList.xml and apply an external document type definition file to it
d)Validate the XML file BookList.xml against a schema that is cached in memory.
e)Read the XML File BookList.xml and create an external document type file definition based on it.

Answer : b (Validate the XML File BookList.xml against a Document Type Definition file)

Explanation :

These lines of code validate the XML File BookList.xml against a document Type Definition(DTD). You use the XmlValidatingReader object to accomplish this. Here an instance of XmlValidatingReader named ValidateRead has been created, with an arguement that points to the file to be validated,BookList.xml. The XmlValidatingReader will validate the document using the DTD list in the XML File's DOCTYPE Declaration.Errors in the XML File are reported through the ValidationHandler method.

The Code does read the XML file, but it doesn't create an external DTD file, nor does it apply one to the XML file.

The Code does not validate the XML file against a schema that is cached in memory, though you can do so using the XmlSchemaCollection object.

The Code doesn't create a new file named BookList.xml. The BookList.xml file must already exist for this code to run successfully.




3.You are using Visual Studio.NET to develop a Windows Service.You are begining to debug your application, and you would like to create an error log of detailed debug message as you proceed with testing.






Which of the following should you use?

a)DefaultTraceListener
b)TextWriterTraceListener
c)EventLogTraceListener
d)TraceSwitch

Answer: b (TextWriterTraceListener)

Explanation:

You should use a TextWriterTraceListener, which sends the output of the Debug or Trace class to a text stream,which you can direct to a text file or to the console window.

The EventLogTraceListener performs a similar function, but sends its output to the Windows event log. You should use the event log primarily to exceptions rather than to record detailed debug messages.

DefaultTraceListener is, as its name implies, the default trace listener. It sends its output to the attached debugger, such as Visual Studio.NET Debugger, which generally displays the information in a message box or a trace window.

TraceSwitch allows you to configure the way Trace Information is displayed. but doesn't actually display information itself.

4.You Plan to Use configuration files(web.config) for an XML Web Service as well as page directives for specific Web Pages included in the service to control globalization for your service.


Which attribute can you define in globalization element of the Web.config file for the service but not in a Page directive for an individual Page?

a)responseEncoding
b)uiCulture
c)culture
d)fileEncoding
e)requestEncoding

Answer: d (fileEncoding)
Explanation :

You can define the fileEncoding attribute only in the globalization element of a web.config file. You use the fileEncoding attribute to identify the format of data in an application's .aspx file

You can define the responseEncoding attribute in either the web.config file or in a Page directive. You use the responseEncoding attribute to designate the encoding that a server uses to send data to a client.

You can define the requestEncoding attribute in either ther web.config file or in a page directive. You use requestEncoding attribute to designate the encoding used in data received from a client by a Web Server.

You can define the culture attribute in either the Web.config file or in a Page directive. You use the culture attribute to designate the format in which language-dependent data should be displayed. For Ex, the culture setting governs how dates and currency values are displayed.

You can define the uiCulture attribute in either the web.config file or in a Page directive. You use the uiCulture attribute to designate the language that should be presented in the user interface(ui).
PART2
1.You have developed three versions of a .NET Remoting component named LicServer that you would like to deploy to a production server. You created installers for each version of the component.Each installer is coded to install a component into the Global Assembly Cache. The three versions are 1.0.0.0, 1.0.0.1, 1.0.0.2. Each component resides in a directory on the C:\ drive named after its version. You want to use the InstallUtil.exe utility to deploy each version of the component side-by-side. You enter the following command on the command line:

InstallUtil c:\1.0.0.0\LicServer.dllc:\1.0.0.1\LicServer.dllc:\1.0.0.2\LicServer.dll

If the installation of Version 1.0.0.2 fails how many components will be installed side-by-side?
a)1
b)0
c)2
d)3

Answer : b (0)

Explanation :

If installation of one assembly fails, the installation will be rolled back, That includes any installations that had already succeeded. This is due to the transactional nature of InstallUtil.exe. If you did not want all installations to fail,you would have to run the InstallUtil.exe utility for each version of the component separately.

2.You have written a class using C# and you want to generate an XSD Schema from the class definition. You want to have granular control over which properties of the class should be persisted as attributes and which ones should be persisted as elements. You also want to be able to control the namespace for the schema.

What tasks should you perform to do so?

a)Apply attributes from the System.Xml.Serialization namespace to the class and its properties. Use System.Xml.Serialization.XmlDeserializer to deserialize the class into a schema.
b)Apply attributes from the System.Xml.Serialization namespace to the class and its properties. Use System.Xml.Serialization.Xmlserializer to deserialize the class into a schema.
c)Apply attributes from the System.Xml.Serialization namespace to the class and its properties. Compile the class and use the xsd.exe tool to generate a schema from the compiled class
d)Compile the class and use the xsd.exe tool to generate a schema from the compiled class. Provide the namespace, attribute, and element options as arguements to the tool.

Answer : c (Apply attributes from the System.Xml.Serialization namespace to the class and its properties. Compile the class and use the xsd.exe tool to generate a schema from the compiled class)

Explanation:

You should apply the attributes from the System.Xml.Serialization namespace to the class and Properties. The XmlElement attribute is applied to properties to indicate that they should be serialized as elements. The XmlAttribute attribute is applied to properties to indicate that they should be serialized as attributes. The XmlRoot attribute is applied to a type to indicate that it should be serialized as the root element of the schema.

You should not use the System.Xml.Serialization.XmlDeserializer to deserialize the class into a schema. The XmlDeserializer deserializes XML Documents into instances of typed objects.

You Should use the System.Xml.Serialization.XmlSerializer to serialize the class into a schema. The XmlSerializer serializes instances of typed objects into XML Documents

You should not provide the namespace, attribute, and element options as arguements to the XSD.exe tool. When generating a schema from a class in an assembly, only the output directory and class type are available as options. These are no options that allow you to control the format of the generated schema. The format is controlled declaratively in the class using attributes from the System.Xml.Serialization
namespace.

3.You are a part of team that is using VisualStudio.NET to develop a Web Service. You are looking through some of the code that your co-workers have written, and you see a line of code that executes the ExecuteXmlReader method.

What is the purpose of this method?
a) It returns the results of an XPath query in XML Format
b) It returns the results of a SQL Query in XML Format
c) It populates a Dataset with data from an XML Document
d) It allows you see to use SQL Query commands to return data from an XML Document

Answer : b (It returns the results of a SQL query in XML Format)

Explanation :

The SqlCommand object's ExecuteXMLReader method returns XML Data from a SQL Server 2000 database. The data is stored in an XMLReader object. You must use a FOR XML clause in the SQL statement that the ExecuteXMLReader uses to direct SQL Server 2000 to deliver the data in XML Format.

The ExecuteXMLReader method doesn't return the results of an XPath query in XML Format. You use ExecuteXMLReader with a SQL query, not with an XPath query.

The ExecuteXMLReader method doesn't populate a Dataset with data from an XML Document. You use ExecuteXMLReader to return an XMLReader object, which is not the same thing as a Dataset.

The ExecuteXMLReader method doesn't allow you to use SQL Query commands to return data from an XML Document. Though it does return XML Data. you use ExecuteXMLReader with a SQL database, not with an XML Document.

4.You have written an Extensible Markup Language (XML) web Service named BackgroundCheckService that derives from a class name BasedDataEncryptionService written by a third party named Service Providers Plus. You add a Web method named GetData that is defined as follows:

[WebMethod(Description='"')]
public string GetData(object value)
{
--------------------
}
You have just downloaded the latest service Pack from service providers Plus, and you now receive build warnings when you compile your code. You discover that Service Providers Plus has added a method named GetData using the same signature as your method and its use is totally different than yours. You don't want to change your method because your Web Service has already been published and is being used by hundreds of client.

What should you do to prevent users of both classes from inadvertently calling the wrong GetData method?
a) Add the Virtual keyword to the method's declaration
b) Add the new keyword to the method's declaration
c) Add the override keyword to the method's declaration
d) Add the abstract keyword to the method's declaration

Answer : b (Add the new keyword to the method's declaration)

Explanation :

You should add the new keyword to the method's declaration. This causes your method to hide the method of the base class that has the same name.

You should not add the virtual keyword to the method's declaration. This would cause a compiler error. A Virtual method can only exist once in a class hierarchy, and it can only exist in the first top-most class that define the method.

You should not add the override keyword to the method's declaration. This would cause your method to override the method in the base class. If a client had a variable declared as a reference to BaseDataEncryptionService, they could inadvertently call your version of GetData when you know the semantics are not the same.

You should not add the abstract keyword to the method's declaration. An abstract method can only exist in an abstract base class. An abstract base class simply defines a contract that inheritors must adhere to. It is very similar to an interface, but it allows for some default implementation.
PART-3
Scenario: You need to create an XML Web Service to provide client applications access to tthe catalogs of various products. You store the product information in an XML File because the product information does not change very often.

Q:What will you do to enable the client applications to access the information stored in a relational Form?

Answer: In the Web Service, create a Web method. Use the ReadXml method of the Dataset to Read data from the XML File into a Dataset object and return the Dataset object.

The ReadXml method allows you to read data from an XML file into a Dataset.

Scenario:

You need to create an applicaton that consists of two serviced components, XMLServer and SQLServer. XMLServer provides access to data stored in XML Files, and SQLServer provides access to data that resides in the SQL Server Database. You need to create the XMLServer and SQLServer components in a system-provided process instead of creator process.

Q: How should you create the application to achieve this objective?

Answer:

using System.EnterpriseServices;

using System;

[assembly:ApplicationActivation(ActivationOption.Server)]

public class XMLServer:ServicedComponent

{

}

public class SQLServer:ServicedComponent

{

}

The value of the ApplicationActivation attribute, which is specified at the assembly level, controls whether the creator's process or a dedicated server process creates the components in an assembly.The ActivationOption.Server value for the ApplicationActivation attribute specifies that a dedicated server process create the components.

Scenario: You created an XML Web Service named MyService. MyService contains a Web method, CalculateInterest that performs lengthy caluculations and uses substantial system resources. The current implementation of the XML Web Service restricts clients from using the data-entry form until the Web method is executed. You need to implement the XML Web Service in such a way that clients need not wait for the Web method to complete execution.

Q:What are the options to accomplishe the above mentioned task?

Answer:

Use the BeginCalculateInterest and EndCalculateInterest methods, and perform asynchronous function calls.

Scenario:

You create an XML Web service, called Service1. You use the Debug.Assert method in your code to verify parameter values and ranges. You find that Service1 doesn't display assertion failure messages. Instead,Service1 returns an HTTP500 error message when an assertion fails.You need to display the assertion failure messages.

Q: How do you enable to do so?

Answer:

You need to modify the compilation element of the Web.config file by setting the debug attribute to True.

PART4

Scenario: You have created a component, called SalesOrders, which provides access to sales order information. The Order Information is stored in the Orders table, the details of orders in the Order_Details table, and Inventory Information in the Inventory Table. The CreateOrder method enables you to crate a new order.The code for CreateOrder method is:

public void CreateOrder()
{
try
{
string connstring="";
connstring="server=localhost;integrated security=sspi; database=northwind";
sqlconnection sqlConn=new SqlConnection(connString);
sqlConn.Open();

SqlTransaction trans;
trans=sqlConn.BeginTransaction();

SqlCommand command=new SqlCommand();
command.Connection=sqlConn;
command.Transaction=trans;

command.CommandText="Insert into orders values(----)";
command.ExecuteNonQuery();
trans.Save("Two");

try
{
command.CommandText="update inventory----";
command.ExecuteNonQuery();
trans.Save("Three");
}
catch(Exception e)
{
trans.Rollback("Two");
}
trans.commit()
}
catch(Exception ex)
{
trans.Rollback();
}
}

Q:How are the inserts and updates committed and rolled back?

Answer:

1.If an insert in the Orders table fails, the entire transaction is rolled back.If an error occurs while inserting records in the Orders table, an exception, which is handled by the outer Try Catch block, is thrown. The Catch block rolls back the entire transaction.If an insert in the Order_details table fails, the entire transaction is rolled back.If updates on the Inventory table fail, inserts in the Orders and Order_Details tables are committed.

2.If an insert in the Order_details table fails, the entire transaction is rolled back.If an error occurs while inserting records in the Order_Details table, an exception, which is handled by the outer Try Catch block, is thrown. The catch block rolls back the entire transaction. If an error occurs while inserting records in the Orders table, an exception, which is handled by the outer Try Catch block, is thrown. The Catch block rolls back the entire transaction. If updates on the Inventory table fail, inserts in the Orders and Order_Details tables are committed.

3.If updates on the Inventory table fail, inserts in the Orders and Order_Details tables are committed.
If an error occurs while updating records in the Orders_Details table, an exception,which is handled by the Inner Try Catch block, is thrown.The inner catch block rolls back the transactions after the savepoint called Two. As a result, inserts in the orders and Order_Details tables are committed.If an error occurs while inserting records in the Order_Details table, an exception, which is handled by the outer Try Catch block, is thrown. The catch block rolls back the entire transaction.If an insert in the Order_Details table fails, the entire transaction is rolled back.


Scenario: You are creating a .NET Remoting application. You register an HttpClientChannel channel, create a remote object, and then register the HttpServerChannel channel in the application domain. However, an error message is displayed when you run the application.

Q: What are the reasons for the error?

Answer:
1. You need to register the server channel before registering the remote object.You need to register the server channel before you can register the remote object.

2.You have two channels in the same domain with the same name.You cannot have two channels with the same name in one domain.

Scenario: You create a DataSet object, productsDataSet, which contains product information from a MS-SQL Server Database. This object has a primarykey in a column, called ProductID. You need to creat a new Dataset object that has the same structure as productsDataSet, including the primary key. The new DataSet object should not contain any data.

Q:What Code Segment do you use?
Answer: Dim newDataset As DataSet=productsDataset.Clone();
The Clone method of the DataSet class copies the structure of the DataSet class, including all DataTable schemas, relations, and constraints. However, the Clone method doesn't copy data.


Scenario: You Create a Web Service and do not want to provide access to users who belong to the InvalidCustomers role.

Q:What should you write in the Web.Config file?

Answer:

"<"authentication mode="Windows"">"
"<"authorization">""<"deny roles="InvalidCustomers"">"
"<"allow roles="*"">"
"<\"authorization">"

You deny access to the InvalidCustomers role and then access is provided to all other roles.

PART5
Scenario: You use a serviced component, FabrikamComponent, in three applications on your computer. Over the Past Six months, You have received a number of updates for FabrikamComponent, all of which you have registered in the global assembly cache. You discover that one application uses version 1.0.2.0, another application uses version 1.0.3.0, and a third application uses version 1.0.5.0 You now receive FabrikamComponent version 2.0.0.0, which is a critical update. You register version 2.0.0.0 in the global assembly cache and verify that version 2.0.0.0 is backward compatible. You need to ensure that all three of your applications use version 2.0.0.0. You need to accomplish this without recompiling all three applications.

Q: How do you enable to do so?
Answer:

Configure a binding policy in the machine.config file that redirects all prior versions of FabrikamComponent version 2.0.0.0 You need to configure a binding policy that redirects all prior versions of FabrikamComponent to version 2.0.0.0 in the machine.config file.

Scenario: Alpine Ski House is moving its ski business online. You have used .NET Remoting to create an application thata accesses methods from an existing application. You need to update the existing list of objects exposed by the application. You specify the following instruction in the application configuration file:

"<"application">"
"<"Service">"
"<"wellknown type="ServerActivatedType, RemoteAssembly" objectUri="Bookings.rem" mode="SingleCall" "/>"
""
""

Q: When you run the application, you cannot access the remote object and receive an error message. What is the reason for that?

Answer:
1.The remote object is not a server-activated object.An error message is displayed if the remote object is not a server-activated object because you have used the wellknown element.

2.The remote object is not present in the application.An error message is displayed if the remote object is not present in the application.

Scenario: You are developing an XML Web service that provides access to product information from MS-SQL Server. The getData web method of XML Web service should return an XmlDocument object. The connectionstring is stored in a String variable, called connStr, and the select statement to retrieve data as XML is stored in a string variable, called sqlStr.

Q:What code should you write for the getData method?
Answer:

SqlConnection conn=new SqlConnection(connStr);
SqlCommand cmd=new SqlCommand(sqlStr,conn);
conn.Open();
SqlDataReader reader=cmd.ExecuteReader;
string str="";
while(reader.Read)
{
str=str&reader.Item[0];
}
str=str+"
";
reader.Close();
XmlDocument doc=new XmlDocument();
doc.LoadXml(str);
return doc;

When you use a select statement to retrieve the records as XML From the SQL Server Database, you can use the ExecuteReader method of the SqlCommand object. The ExecuteReader method of the SqlCommand object returns an SqlDataReader object. The code creates a well formed XML Document.In addition, You can use the ExecuteXmlReader method of the SqlCommand Object can be called to return an XmlReader object. The code in option a uses the XmlReader object to create a well-formed XmlDocument object.

2.SqlConnection conn=new SqlConnection(connStr);
SqlCommand cmd=new SqlCommand(sqlStr,conn);
conn.Open();
XmlReader reader=cmd.ExecuteXmlReader();
XmlDocument XmlDoc= new XmlDocument();
XmlElement root;
root=XmlDoc.AppendChild(XmlDoc.CreateElement("XmlRoot"));
do
{
nodRoot.AppendChild(XmlDoc.ReadNode(reader));
}while(!reader.EOF);
reader.Close();
conn.Close();
return XmlDoc;

When you use a Select Statement to retrieve the records as XML from the SQL Server database, the ExecuteXmlReader method of the SqlCommand object can be called to return an XmlReader object. The code uses the XmlReader object to create a well-formed XmlDocument object. In addition to using the ExecuteXmlReader method, you can use the ExecuteReader method to retrieve XML Data. The ExecuteReader method of the SqlCommand object returns an SqlDataReader object.


Scenario: Contoso Inc hosts a Web site that allows you to search for a particular software product and download the product. You need to provide the following information to search for a particular product:

a)Product Name
b)Operating System

This information is displayed using a DataGrid control. You added three columns to the DataGrid control at design time.

The search displays information such as ProductName,Product Description, and Size. The page also provides a CheckBox Control that enables the user to choose which information is displayed. If the CheckBox control is checked, the page displays ProductName, ProductDescription, and Size. If the CheckBox control is unchecked, the page displays Product Name and Size.

Q: How do you implement the required functionality in the Contoso,Inc. Website?

Answer:

DataGrid1.Columns[1].Visible=!(DataGrid1.Columns[1].Visible);

The Product Description Column is the Second Column. You need to use the DataGrid1.Columns[1].Visible=!(DataGrid1.Columns[1].Visible) statement.

0 comments: