Latest MCTS 70-513 Dumps Real Exam Download 21-30

Ensurepass

QUESTION 21

A Windows Communication Foundation (WCF) solution uses the following contracts. (Line numbers are included for reference only.)

01 [ServiceContract(CallbackContract=typeof(INameService))]

02 public interface IGreetingService

03 {

04 [OperationContract]

05 string GetMessage();

06 }

07

08 [ServiceContract]

09 public interface INameService

10 {

11 [OperationContract]

12 string GetName();

13 }

When the client calls GetMessage on the service interface, the service calls GetName on the client callback. In the client, the class NameService implements the callback contract. The client channel is created as follows:

22 InstanceContext callbackContext = new InstanceContext(new NameService(“client”));

23 …

24 …

25 DuplexChannelFactory<IGreetingService> factory = new DuplexChannelFactory<IGreetingService>(typeof(NameService), binding, address);

26 IGreetingService greetingService = factory.CreateChannel();

You need to ensure that the service callback is processed by the instance of NameService.

What are two possible ways to achieve this goal? (Each correct answer presents a complete solution. Choose two.)

 

A. Change line 25 to the following code segment:

DuplexChannelFactory<IGreetingService> factory = new DuplexChannelFactory<IGreetingService>(callbackContext, binding, address);

B. Change line 26 to the following code segment:

IGreetingService greetingServicefactory = CreateChannel(callbackContext);

C. Add the following code segment after line 26:

callbackContext.IncomingChannels.Add((IDuplexChannel)greetingService);

D. Add the following code segment after line 26:

callbackContext.OutgoingChannels.Add((IDuplexChannel)greetingService);

 

Correct Answer: AB

Explanation/Reference:

Example 1:

// Construct InstanceContext to handle messages on callback interface

InstanceContext instanceContext = new InstanceContext(new CallbackHandler());

// Create a client

CalculatorDuplexClient client = new CalculatorDuplexClient(instanceContext);

 

 

QUESTION 22

A Windows Communication Foundation (WCF) solution exposes the following contract over an HTTP connection.

[ServiceContract]public interface IDataService{

 [OperationContract]string GetData();}

Existing clients are making blocking calls to GetData. Calls to GetData take five seconds to complete.

You need to allow new clients to issue non-blocking calls to get the data, without breaking any existing clients. What should you do?

 

A. Replace the service interface with the following interface and implement the new methods.

[ServiceContract]

public interface IDoSomething

{

 [OperationContract]

string DoLongOperation();

 [OperationContract(AsyncPattern = true)]

IAsyncResult BeginDoLongOperation();

 [OperationContract(AsyncPattern = true)]

string EndDoLongOperation(IAsyncResult result);

}

B. Replace the service interface with the following interface and implement the new methods.

[ServiceContract]

public interface IDoSomething

{

 [OperationContract(AsyncPattern = true)]  IAsyncResult BeginDoLongOperation();

 [OperationContract(AsyncPattern = true)]

string EndDoLongOperation(IAsyncResult result);

}

C. Generate a proxy class with asynchronous methods and use it for the new clients.

D. Add a new endpoint to the service that uses a full-duplex binding and use it for the new clients.

 

Correct Answer: C

Explanation/Reference:

 

 

QUESTION 23

A Windows Communication Foundation (WCF) service implements the following contract. (Line numbers are included for reference only.)

01 [ServiceContract]

02 public interface IDataAccessService

03 {

04 [OperationContract]

05 void PutMessage(string message);

06 …

07 [OperationContract]

08 [FaultContract(typeof(TimeoutFaultException))]

09 [FaultContract(typeof(FaultException))]

10 string SearchMessages(string search);

11 }

The implementation of the SearchMessages method throws TimeoutFaultException exceptions for database timeouts.

The implementation of the SearchMessages method also throws an Exception for any other issue it encounters while processing the request.

These exceptions are received on the client side as generic FaultException exceptions.

You need to implement the error handling code for SearchMessages and create a new channel on the client only if the channel faults.

What should you do?

 

A. Catch and handle both TimeoutFaultException and FaultException.

B. Catch both TimeoutFaultException and FaultException. Create a new channel in both cases.

C. Catch and handle TimeoutFaultException. Catch FaultException and create a new channel.

D. Catch and handle FaultException. Catch TimeoutFaultException and create a new channel.

 

Correct Answer: C

Explanation/Reference:

 

 

QUESTION 24

You are consuming a Windows Communication Foundation (WCF) service in an ASP. NET Web application. The service interface is defined as follows:

[ServiceContract]public interface ICatalog{

 [OperationContract]

[WebGet(UriTemplate=”/Catalog/Items/{id}”, ResponseFormat=WebMessageFormat.Json)]

string RetrieveItemDescription(int id);

}

The service is hosted at Catalogsvc.

You need to call the service using jQuery to retrieve the description of an item as indicated by a variable named itemId.

Which code segment should you use?

 

A.            $get(String.format(“/Catalogsvc/Catalog/Items/id{0}”, itemId) null, function (data) { … }, javascript”);

B.            $get(String.format(“/Catalogsvc/Catalog/Items/{0}”, itemId), null, function (data) { … }, “json”);

C.            $get(String.format(“/Catalogsvc/Catalog/Items/{0}”, itemld), null, function (data) { … }, “xml”);

D.            $get(String.format(“/Catalogsvc/Catalog/Items/id{0}”, itemld), null, function (data) { … }, “json”);

 

Correct Answer: B

Explanation/Reference:

 

 

QUESTION 25

You are consuming a Windows Communication Foundation (WCF) service. The service interface is defined as follows:

[DataContract(Namespace = ”]public class Item{

}

[ServiceContract(Namespace = ”)]public interface Catalog{

[OperationContract][WebInvoke(Method=”POST”, UriTemplate=”{Item}”)]Item UpdateItem(Item item);}

The client application receives a WebResponse named response with the response from the service.

You need to deserialize this response into a strongly typed object representing the return value of the method.

Which code segment should you use?

 

A.            DataContractSerializer s = new DataContractSerializer(typeof(Item));Item item = s.ReadObject(response.GetResponseStream()) as Item;

B.            BinaryFormatter f = new BinaryFormatter();Item item = f.Deserialize(response.GetResponseStream() as Item;

C.            XmlDictionaryReader r = JsonReaderWriterFactory.CreateJsonReader(response.GetResponseStream(), XmlDictionaryReaderQuotas.Max);DataContractSerializer s = new DataContractSerializer(typeof(Item));Item item = s.ReadObject(r) as Item;

D.            DataContractJsonSerializer s = new DataContractJsonSerializer(typeof(Item));Item item = s.ReadObject(response.GetResponseStream()) as Item;

 

Correct Answer: A

Explanation/Reference:

Use the DataContractSerializer class to serialize and deserialize instances of a type into an XML stream or document.

For example, you can create a type named Person with properties that contain essential data, such as a name and address.

You can then create and manipulate an instance of the Person class and write all of its property values in an XML document for later retrieval,

or in an XML stream for immediate transport. Most important, the DataContractSerializer is used to serialize and deserialize data sent in messages.

Apply the DataContractAttribute attribute to classes, and the DataMemberAttribute attribute to class members to specify properties and fields that are serialized.

Serialization and Deserialization

(http://msdn.microsoft.com/en-us/library/ms731073%28v=VS.100%29.aspx)

 

 

QUESTION 26

A Windows Communication Foundation (WCF) application exposes a service as a SOAP endpoint for consumption by cross-platform clients.

During integration testing, you find that one of the clients is not generating the correct messages to the WCF application.

In order to debug the issue and fix the communication, you need to configure the service to log messages received from the client.

What should you do?

 

A. Set an etwTracking behavior on the service and configure a listener for the System.ServiceModel trace source.

B. Set an etwTracking behavior on the service and configure a listener for the System.ServiceModel.MessageLogging trace source.

C. Enable messageLogging in the System.ServiceModel diagnostics element configuration and configure a listener for the System.ServiceModel.MessageLogging trace source.

D. Enable messageLogging in the System.ServiceModel diagnostics element configuration and configure a listener for the System.ServiceModel trace source.

 

Correct Answer: C

Explanation/Reference:Configuring Message Logging

(http://msdn.microsoft.com/en-us/library/ms730064.aspx)

Example:

<system.diagnostics><sources> <source name=”System.ServiceModel.MessageLogging”>

<listeners> <add name=”messages”type=”System.Diagnostics.XmlWriterTraceListener”initializeData=”c:logsmessages.svclog” />

</listeners></source></sources></system.diagnostics>

<system.serviceModel><diagnostics>

<messageLogginglogEntireMessage=”true”logMalformedMessages=”false”logMessagesAtServiceLevel=”true”logMessagesAtTransportLevel=”false”maxMessagesToLog=”3000″maxSizeOfMessageToLog=”2000″/>

</diagnostics></system.serviceModel>

 

 

QUESTION 27

A Windows Communication Foundation (WCF) service interacts with the database of a workflow engine.

Data access authorization is managed by the database, which raises security exceptions if a user is unauthorized to access it.

You need to ensure that the application transmits the exceptions raised by the database to the client that is calling the service.

Which behavior should you configure and apply to the service?

 

A. routing

B. serviceDebug 

C. serviceSecurityAudit 

D. workflowUnhandledException 

 

Correct Answer: B 

Explanation 

Explanation/Reference:serviceDebugserviceSecurityAuditworkflowUnhandledException                                  Specifies debugging and help information features for a Windows Communication Foundation (WCF) service. Specifies settings that enable auditing of security events during service operations.         A service behavior that enables you to specify the action to take when an unhandled exception occurs within a workflow service. 

Setting includeExceptionDetailInFaults to true allows the service to return any exception that is thrown by the application code even if the exception is not declared using the FaultContractAttribute. This setting is useful when debugging cases where the server is throwing an unexpected exception. By using this attribute, a serialized form of the unknown exception is returned and you can examine more details of the exception.

<serviceDebug>

(http://msdn.microsoft.com/en-us/library/ms788993.aspx)

 

 

QUESTION 28

A Windows Communication Foundation (WCF) client application is consuming an RSS syndication feed from a blog.

You have a SyndicationFeed variable named feed. The application iterates through the items as follows.

(Line numbers are included for reference only.)

01 foreach (SyndicationItem item in feed.Items)

02 {

03 }

You need to display the content type and body of every syndication item to the console. Which two lines of code should ou insert between lines 02 and 03?

 

A.ConsoleWriteLine(item.Content.Type);ConsoleWriteLine(((TextSyndicationContent)item.Content).Text);

B.Console.WriteLine(item.Content.GetType());Console.WriteLine(((TextSyndicationContent)item.Content).Text);

C.            Console.WriteLine(item.Content.Type);Console.WriteLine(item.Content.ToString());

D.            Console.WriteLine(item.Content.GetType());Console.WriteLine(item.Content.ToString());

 

Correct Answer: A

Explanation/Reference:

SyndicationItem Class Represents a feed item, for example an RSS <item> or an Atom <entry>.

TextSyndicationContent Represents any SyndicationItem content intended to be displayed to an end user. Properties:

 AttributeExtensions Gets the attribute extensions for this content. (Inherited from SyndicationContent.)

 Text Gets the text of the TextSyndicationContent.

 Type Gets the content type of the TextSyndicationContent. (Overrides SyndicationContent.Type.)

SyndicationItem Class

(http://msdn.microsoft.com/en-us/library/system.servicemodel.syndication.syndicationitem.aspx)

4.1 ATOM 1.0 Formatted Feed

(http://msdn.microsoft.com/en-us/library/ee682805(v=office.12).aspx)

4.2 RSS 2.0 Formatted Feed

(http://msdn.microsoft.com/en-us/library/ee682799(v=office.12).aspx)

 

 

QUESTION 29

You are creating a Windows Communication Foundation (WCF) service to process orders. The data contract for the order is defined as follows:

[DataContract]public class Order{

[DataMember]

public string CardHolderName { get; set; }

[DataMember]

public string CreditCardNumber { get; set; }

}

You have the following requirements:

Enable the transmission of the contents of Order from the clients to the service.

Ensure that the contents of CreditCardNumber are not sent across the network in clear text.

Ensure that the contents of CreditCardNumber are accessible by the service to process the order.

You need to implement the service to meet these requirements. What should you do?

 

clip_image002

Correct Answer: B

Explanation/Reference:

A message contract can indicate whether the headers and/or body of the message should be digitally signed and encrypted.

This is done by setting the System.ServiceModel.MessageContractMemberAttribute.ProtectionLevel property on the MessageHeaderAttribute and MessageBodyMemberAttribute attributes.

The property is an enumeration of the System.Net.Security.ProtectionLevel type and can be set to None (no encryption or signature), Sign (digital signature only), or EncryptAndSign (both encryption and a digital signature). The default is EncryptAndSign.

Using Message Contracts

(http://msdn.microsoft.com/en-us/library/ms730255.aspx)

 

 

QUESTION 30

You are creating a Windows Communication Foundation (WCF) service that accepts messages from clients when they are started. The message is defined as follows:

[MessageContract]public class Agent{

 public string CodeName { get; set; }public string SecretHandshake { get; set; }}

You have the following requirements:

The CodeName property must be sent in clear text.

The service must be able to verify that the property value was not changed after being sent by the client.

The SecretHandshake property must not be sent in clear text and must be readable by the service.

What should you do?

 

A. Add a MessageBodyMember attribute to the CodeName property and set the ProtectionLevel to Sign. Add a MessageBodyMember attribute to the SecretHandshake property and set the ProtectionLevel to EncryptAndSign.

B. Add a DataProtectionPermission attribute to the each property and set the ProtectData property to true.

C. Add an xmlText attribute to the CodeName property and set the DataType property to Signed. Add a PasswordPropertyText attribute to the SecretHandshake property and set its value to true.

D. Add an ImmutableObject attribute to the CodeName property and set its value property to true. Add a Browsable attribute to the SecretHandshake property and set its value to false.

 

Correct Answer: A

Explanation/Reference:

A message contract can indicate whether the headers and/or body of the message should be digitally signed and encrypted.

This is done by setting the System.ServiceModel.MessageContractMemberAttribute.ProtectionLevel property

on the MessageHeaderAttribute and MessageBodyMemberAttribute attributes.

The property is an enumeration of the System.Net.Security.ProtectionLevel type and can be set to None (no encryption or signature),

Sign (digital signature only), or EncryptAndSign (both encryption and a digital signature). The default is EncryptAndSign.

For these security features to work, you must properly configure the binding and behaviors.

If you use these security features without the proper configuration (for example, attempting to sign a message without supplying your credentials),

an exception is thrown at validation time.

For message headers, the protection level is determined individually for each header.

For message body parts, the protection level can be thought of as the “minimum protection level.”

The body has only one protection level, regardless of the number of body parts.

The protection level of the body is determined by the highest ProtectionLevel property setting of all the body parts.

However, you should set the protection level of each body part to the actual minimum protection level required.

Using Message Contracts

(http://msdn.microsoft.com/en-us/library/ms730255.aspx)

Consider the class in the following code example.

[MessageContract]public class PatientRecord{

 [MessageHeader(ProtectionLevel=None)] public int recordID;

[MessageHeader(ProtectionLevel=Sign)] public string patientName;

[MessageHeader(ProtectionLevel=EncryptAndSign)] public string SSN;

[MessageBodyMember(ProtectionLevel=None)] public string comments;

[MessageBodyMember(ProtectionLevel=Sign)] public string diagnosis;

[MessageBodyMember(ProtectionLevel=EncryptAndSign)] public string medicalHistory;

}

 

Download Latest MCTS 70-513 Real Free Tests , help you to pass exam 100%.