Exam Prep Questions

Team-Fly    

Developing XML Web Services and Server Components with Visual C#™ .NET and the .NET Framework, Exam Cram™ 2 (Exam 70-320)
By Amit Kalani, Priti Kalani

Table of Contents
Chapter 6.  Advanced Web Services


Question 1

You are designing a SOAP extension to modify outgoing Web method calls. The extension will run on the client, and when it discovers an obsolete parameter name in the SOAP request, it will replace this with the new parameter name. In which message stage should you invoke this SOAP extension?

  • A. BeforeSerialize

  • B. AfterSerialize

  • C. BeforeDeserialize

  • D. AfterDeserialize

A1:

Answer B is correct. On the client side, outgoing SOAP requests are serialized from objects into XML. The XML is available in the AfterSerialize message stage, after which it is sent to the server. Answer A is incorrect because XML messages do not exist in the BeforeSerialize state. Answers C and D are incorrect because the SOAP extension is designed to work with outgoing messages; these stages occur during incoming messages.

Question 2

Your code is making asynchronous calls to two different Web methods. You want other processing in your code to continue while these methods execute. When either asynchronous call is finished, you want to process its results. How should your code wait for the results of the asynchronous calls?

  • A. Use a separate WaitHandle.WaitOne() method call for each Web method.

  • B. Use a separate callback delegate method for each Web method.

  • C. Use a WaitHandle.WaitAny() method call, specifying both Web methods.

  • D. Use a WaitHandle.WaitAll() method call, specifying both Web methods.

A2:

Answer B is correct. To continue processing until the results of the Web methods are available, you should use callback delegates. Answers A, C, and D are incorrect because using any of the WaitHandle methods will block your code at the point where the method of the WaitHandle object is called until the method that you are waiting for returns.

Question 3

You have developed a SOAP extension that will compress messages on the server and then decompress them on the client. You plan to use this extension for both requests and responses. Which of these processing stages would be an appropriate place to call this extension? (Select two.)

  • A. BeforeSerialize on the server

  • B. AfterSerialize on the client

  • C. BeforeDeserialize on the client

  • D. AfterDeserialize on the server

A3:

Answers B and C are correct. This extension needs to be called during the AfterSerialize and BeforeDeserialize stages on both client and server. These are the stages during which you can work with the raw messages as they are passed over the wire. Answer A is incorrect because if you encrypt the message before serialization, it will not be possible to decrypt it. Similarly, Answer D is incorrect because you won't be able to decrypt the message after deserialization.

Question 4

You are developing a client-side SOAP extension named TraceExt. Your project includes the TraceExt class and an attribute class named TraceExtAttribute. It also includes a form with a button that uses the following code to invoke a Web method:

 private void btnRunMethod_Click(     object sender, System.EventArgs e) {    // Call a Web method on the Sales object    SalesWebService.Sales S = _      new SalesWebService.Sales();     txtSales.Text = S.GetSales(); } 

Where should you apply the TraceExtAttribute attribute to activate the SOAP extension?

  • A. To the GetInitializer() method in the TraceExt class

  • B. To the Initialize() method in the TraceExt class

  • C. To the btnRunMethod_Click() event handler in the form

  • D. To the GetSales() method in the Web service proxy class

A4:

Answer D is correct. To invoke a SOAP extension on the client side, you should add an attribute for the extension to the Web method declaration in the proxy class. Answers A, B, and C are incorrect because attributes for the SOAP extension should be applied to the Web method.

Question 5

Your code has made an asynchronous call to a Web method and is now continuing with processing. You've reached a point that you could handle the return value from the asynchronous call, if it's available, or continue with other processing. How can you check to see whether the asynchronous call is finished without blocking?

  • A. Test the value of the IAsyncResult.IsCompleted property.

  • B. Call the WaitHandle.WaitOne() method.

  • C. Call the End method for the asynchronous Web method.

  • D. Call the WaitHandle.WaitAny() method.

A5:

Answer A is correct. The IsCompleted property returns true if the results of the asynchronous Web method call are available, without blocking the code where you check the property. Answers B, C, and D are incorrect because they would block the code waiting for the method to return.

Question 6

You are writing a Web service named Sales in Visual C# .NET. The Web service will be consumed by a client that expects to use SOAP Section 7 formatting for all messages and SOAP Section 5 formatting for all parameters. How should you declare the Sales Web service?

  • A.

     [SoapDocumentService(   Use=SoapBindingUse.Encoded), WebService(   Namespace="http://sales.myco.com/")] public class Sales 
  • B.

     [SoapRpcService(   Use=SoapBindingUse.Encoded), WebService(   Namespace="http://sales.myco.com/")] public class Sales 
  • C.

     [SoapDocumentService(   Use=SoapBindingUse.Encoded,   ParameterStyle=     SoapParameterStyle.Wrapped), _ WebService(   Namespace="http://sales.myco.com/")] public class Sales 
  • D.

     [SoapRpcService(), WebService(   Namespace="http://sales.myco.com/")] public class Sales 
A6:

Answer D is correct. For SOAP Section 7 messages, you need to use the SoapRpcService attribute. This attribute automatically uses SOAP Section 5 encoding for parameters. Answer B is incorrect because the SoapRpcService attribute does not include a Use property; this can't be configured. Answers A and C are incorrect because the SoapDocumentService attribute does not generate SOAP Section 7 messages.

Question 7

You are developing a SOAP extension that will record the average number of requests for a particular Web method each minute. These results will be written to a file for later analysis. The filename is specified in a configuration file and will not change while the Web service is running. In which method should you read the name of this file?

  • A. GetInitializer()

  • B. Initialize()

  • C. ChainStream()

  • D. ProcessMessage()

A7:

Answer A is correct. The GetInitializer() is called when the SOAP extension is first loaded; therefore, the filename can be read once at this time. Answer B is incorrect because the Initialize() method is called every time that the SOAP extension is invoked; setting up the file in this method would result in duplication of effort. Answer C is incorrect because the ChainStream() method is used to intercept the SOAP messages during serialization and deserialization. Answer D is incorrect because the ProcessMessage() method is not suitable for one-time initialization but is used to work with the SOAP messages and implement SOAP extenstions.

Question 8

You are installing two SOAP extensions to a particular Web service. The first extension, named SoapEncrypt, is designed to use symmetric cryptography to encrypt SOAP messages. The second extension, named SoapTranslate, is designed to translate key words in the SOAP message from English to French.

You want the SoapTranslate extension to be invoked before the SoapEncrypt extension. Which priorities should you set for the two extensions?

  • A. Set the priority of the SoapTranslate extension to -1 and the priority of the SoapEncrypt extension to 0.

  • B. Set the priority of the SoapTranslate extension to 0 and the priority of the SoapEncrypt extension to 1.

  • C. Set the priority of the SoapTranslate extension to 1 and the priority of the SoapEncrypt extension to 0.

  • D. Set the priority of the SoapTranslate extension to 0 and the priority of the SoapEncrypt extension to -1.

A8:

Answer B is correct. SOAP extensions with a lower-priority value are invoked first. Answers A and D are incorrect because the lowest possible priority value is 0. Answer C is incorrect because SOAP extensions are invoked in the order of their increasing priority.

Question 9

You have created a Web method named GetSales() with the following declaration:

 [WebMethod()] public int GetSales(string strCompanyName) 

Your corporate standards call for using Hungarian naming (with the str prefix) for variables. However, the developer of the client application that will call this Web method used the name CompanyName (without a prefix) for the parameter. How should you fix this problem?

  • A. Rewrite your code to use CompanyName as the parameter name.

  • B. Use the SoapDocumentMethod attribute to specify the SoapParameterStyle.Bare parameter style for this method.

  • C. Use the XmlElement attribute to rename the parameter in the SOAP messages.

  • D. Use the SoapDocumentMethod attribute with Use=SoapBindingUse.Literal to specify literal encoding for this method.

A9:

Answer C is correct. The XmlElement attribute enables you to specify a different name for a parameter in a SOAP message than the name that you use in your actual code. Answer A is incorrect because although rewriting the code would solve the problem, there's no reason to ignore corporate standards when you don't have to do so. Answers B and D are incorrect because the parameter style or encoding will not help you to provide a different name for the parameter.

Question 10

You have deployed a Web service and a set of client applications. Now you are ready to deploy version 2 of the Web service, which changes the name of a parameter in one of the Web methods. How can you deploy version 2 of the Web service without breaking the version 1 clients?

  • A. Use the XmlElement attribute to rename the parameter in the Web method.

  • B. Use the SoapDocumentMethod attribute to rename the parameter in the Web method.

  • C. Use a try-catch block in the Web service to catch the error when the old parameter is invoked and rename it to the new parameter.

  • D. Use a SOAP extension on the server to detect the old parameter name and change it to the new parameter name before the message is processed.

A10:

Answer D is correct. The SOAP extension can rewrite incoming SOAP requests before they are deserialized into objects. Answer A is incorrect because the XmlElement attribute won't work; it specifies the only name to use, not an alternate name. Answer C is incorrect because exception handling won't work; the code will fail during deserialization before the Web method is actually called. Answer B is incorrect because the SoapDocumentMethod does not enable you to rename a parameter.


    Team-Fly    
    Top


    MCAD Developing XML Web Services and Server Components with Visual C#. NET and the. NET Framework Exam Cram 2 (Exam Cram 70-320)
    Managing Globally with Information Technology
    ISBN: 789728974
    EAN: 2147483647
    Year: 2002
    Pages: 179

    flylib.com © 2008-2017.
    If you may any questions please contact us: flylib@qtcs.net