Latest MCTS 70-513 Dumps Real Exam Download 41-50

Ensurepass

QUESTION 41

clip_image002

A. Add the following attributes to the SavePerson operation on IContosoService.

[OperationBehavior(TransactionScope.Required = true)]

[TransactionFlow(TransactionFlowOption.Mandatory)]

B. Add the following attributes to the SavePerson operation on lContosoService

[TransactionFlow(TransactionFlowOption.Mandatory)]

[OperationBehavior(TransactionScope.Required = true)]

C. Add the following attribute to the SavePerson operation on lContosoService

[OperationBehavior(TransactionScope.Required = true)]

Add the following attribute to the implementation of SavePerson.

[TransactionFlow(TransactionFlowOption.Allowed)]

D. Add the following attribute to the SavePerson operation on lContosoService

[TransactionFlow(TransactionFlowOption.Allowed)]

Add the following attribute to the implementation of SavePerson.

[OperationBehavior(TransactionScope.Required = true)]

 

Correct Answer: D

Explanation/Reference:

The TransactionFlowAttribute is an attribute used declaratively to associate a specific transaction flow policy with a service operation.

The TransactionFlowOption property of this attribute specifies whether the respective operation accepts a transaction flowed from the client,

or if the operation requires the client to always flow a transaction. The TransactionFlowAttribute can also be used as an operation behavior

to programmatically associate a transaction flow policy with a specific operation. In this case, it should be added to the Behaviors

collection on the operation’s description.

Transaction Flow Settings

Transaction flow settings are generated for a service endpoint as a result of the intersection of the following three values:

The TransactionFlowAttribute attribute specified for each method in the service contract.

The TransactionFlow binding property in the specific binding.

The TransactionFlowProtocol binding property in the specific binding. The TransactionFlowProtocol binding property enables you to choose

among two different transaction protocols that you can use to flow a transaction. The following sections briefly describe each of them.

How to: Create a Transactional Service

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

 

 

QUESTION 42

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

01 [ServiceContract(SessionMode = SessionMode.Required)]

02 public interface IContosoService

03 {

04 [OperationContract(IsOneWay = true, IsInitiating = true)]

05 void OperationOne(string value);

06

07 [OperationContract(IsOneWay = true, IsInitiating = false)]

08 void OperationTwo(string value);

09 }

The service is implemented as follows:

10 class ContosoService: IContosoService

11 {

12 public void OperationOne(string value) {…}

13 …

14 public void OperationTwo(string value) {…}

15 }

ContosoService uses NetMsmqBinding to listen for messages. The queue was set up to use transactions for adding and removing messages.

You need to ensure that OperationOne and OperationTwo execute under the same transaction context when they are invoked in the same session.

What should you do?

 

A. Insert the following attribute to OperationOne on lContosoService

[TransactionFlow(TransactionFlowOption.Mandatory)]

Insert the following attribute to OperationTwo on IContosoService

[TransactionFlow(TransactionFlowOption.Mandatory)]

B. Insert the following attribute to OperationOne on ContosoService

[OperationBehavior(TransactonScopeRequired=true, TransactionAutoComplete=false)]

Insert the following attribute to OperationTwo on ContosoService.

[OperationBehavior(TransactionScopeRequired=true, TransactionAutoComplete=true)]

C. Add the following XML segment to the application config file in the system serviceModel/bindings configuration section

<netMsmqBinding>

<binding name=”contosoTx” durable=”true” receiveContextEnabled=”true” />

</netMsmqBinding>

Then use the NetMsmqBinding named contosoTx to listen for messages from the clients.

D. Add the following XML segment to the application config file in the systemserviceModel/bindings configuration section.

<customBinding>

<binding name=”contosoTx”>

<transactionFlow />

<binaryMessageEncoding />

<msmqTransport durable=”true” />

</binding>

</customBinding>

Then use the CustommiBinding named contosoTx to listen fcw messages from the clients.

 

Correct Answer: B

Explanation/Reference:

The OperationBehaviorAttribute attribute is a programming model feature that enables common features that developers otherwise must implement themselves.

The AutoDisposeParameters property controls whether parameter objects passed to an operation are disposed when the operation completes.

The TransactionAutoComplete property specifies whether the transaction in which the method executes is automatically committed if no unhandled exceptions occur.

The TransactionScopeRequired property specifies whether a method must execute within a transaction.

The Impersonation property specifies whether the service operation can, must, or cannot impersonate the caller’s identity.

The ReleaseInstanceMode property specifies when service objects are recycled during the method invocation process.

TransactionFlowOption is a ServiceBehavior feature

ServiceModel Transaction Attributes

(http://msdn.microsoft.com/en-us/library/ms730250(v=vs.90).aspx)

 

 

QUESTION 43

A WCF service code is implemented as follows. (Line numbers are included for reference only)

01 [ServiceContract]

02 [ServiceBehavior(InstanceContextMode =

03 InstanceContextMode.Single)]

04 public class CalculatorService

05 {

06 [OperationContract]

07 public double Calculate(double op1, string op, double op2)

08 {

09 }

10 }

You need to increase the rate by which clients get the required response from the service.

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

 

A. Change the service behavior to the following:

[ServiceBehavior(InstanceContextMode=InstanceContextMode.Single, ConcurrencyMode=ConcurrencyMode.Multiple)]

B. Change the service behavior to the following.

[ServiceBehavior(InstanceContextMode=InstanceContextMode.PerCall)]

C. Require the clients use threads, the Parallel Task Library, or other mechanism to issue service calls in parallel.

D. Require the clients to use async operations when calling the senvice.

 

Correct Answer: AB

Explanation/Reference:

The ConcurrencyMode property interacts with some other settings. For example, if the InstanceContextMode value is set to Single the result is that your service can only process one message at a time unless you also set the ConcurrencyMode value to Multiple.

InstanceContextMode Enumeration PerSession A new InstanceContext object is created for each session. PerCall    A new InstanceContext object is created prior to and recycled subsequent to each call. If the channel does not create a session this value behaves as if it were PerCall. Single    Only one InstanceContext object is used for all incoming calls and is not recycled subsequent to the calls. If a service object does not exist, one is created.

Note For singleton lifetime behavior (for example, if the host application calls the ServiceHost constructor and passes an object to use as the service), the service class must set InstanceContextMode to InstanceContextMode.Single, or an exception is thrown when the service host is opened.

ConcurrencyMode Enumeration

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

 

 

QUESTION 44

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 [ServiceContract]

08 public interface INameService

09 {

10 [OperationContract]

11 string GetName();

12 }

The code that implements the IGreetingService interface is as follows:

20 public class GreetingService : IGreetingService

21{

22 public string GetMessage()

23 {

24 INameService clientChannel = OperationContext.Current.GetCallbackChannel<INameService>();

25 string clientName = clientChannel.GetName();

26 return String.Format(“Hello {0}”, clientName);

27 }

28 }

The service is self-hosted. The hosting code is as follows:

30 ServiceHost host = new ServiceHost(typeof(GreetingService));

31 NetTcpBinding binding = new NetTcpBinding(SecurityMode.None);

32 host.AddServiceEndpoint(“MyApplication.IGreetingService”, binding, “net.tcp//localhost:12345”);

33 host.Open();

The code that implements the lNameService interface is as follows:

40 class NameService : INameService

41 {

42 string name;

43 public NameService(string name)

44 {

45 this.name = name;

46 }

47 public string GetName()

48 {

49 return name;

50 }

51 }

Currently, this code fails at runtime, and an InvalidOperationException is thrown at line 25.

You need to correct the code so that the call from the service back to the client completes successfully.

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

 

A. Change the service contract definition in line 01 as follows.

[ServiceContract(CallbackContract = typeof(INameService), SessionMode = SessionMode.Required)]

B. Add the following attribute to the NameService class, before line 40.

[ServiceBehavior(ConcurrencyMode = ConcurrencyMode.Reentrant)]

C. Add the following attribute to the GreetingService class, before line 20.

[ServiceBehavior(ConcurrencyMode = ConcurrencyMode.Reentrant)]

D. Add the following attribute to the GreetingService class, before line 20.

[ServiceBehavior(ConcurrencyMode = ConcurrencyMode.Multiple)]

 

Correct Answer: CD

Explanation/Reference:ConcurrencyMode Enumeration

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

 

 

QUESTION 45

A Windows Communication Foundation (WCF) service has the following contract:

[ServiceContract]public class ContosoService{

 [OperationContract]

[TransactionFlow(TransactionFlowOption.Mandatory)]

[OperationBehavior(TransactionScopeRequired=true, TransactionAutoComplete=false)]

void TxOp1(string value) {… };

 [OperationContract(IsTerminating=true)]

[TransactionFlow(TransactionFlowOption.Mandatory)]

[OperationBehavior(TransactionScopeRequired=true, TransactionAutoComplete=false)]

void TxOp2(string value)

{

 … OperationContext.Current.SetTransactionComplete();}}

The service and the clients that call the service use NetTcpBinding with transaction flow enabled.

You need to configure the service so that when TxOp1 and TxOp2 are invoked under the same client session,

they run under the same transaction context. What should you do?

 

A. Update the service contract to read as follows.

[ServiceContract(SessionMode=SessionMode.Required)]

Add the following behavior to the service implementation

[ServiceBehavior(InstanceContextMode=InstanceContextMode.PerSession)]

B. Update the service contract to read as follows.

[ServiceContract(SessionMode=SessionMode.Allowed)]

Add the following behavior to the service implementation.

[ServiceBehavior(InstanceContextMode=InstanceContextMode.Single, ReleaseServiceInstanceOnTransactionComplete=false)]

C. Update the service contract to read as follows

[ServiceContract(SessionMode=SessionMode.Allowed)]

Add the followng behavior to the service implementation.

[ServiceBehavior(InstanceContextMode=InstanceContextMode.Single)]

D. Update the service contract to read as follows.

[ServiceContract(SessionMode=SessionMode.Required)]

Add the following behavior to the service implementation.

[ServiceBehavior(InstanceContextMode=InstanceContextMode.PerCall)]

 

Correct Answer: A

Explanation/Reference:

To participate in the same transaction both calls should be part of the same session. SessionMode.Required is required to enforce sessions for the endpoint.

InstanceContextMode Enumeration

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

SessionMode Enumeration

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

 

 

QUESTION 46

You are creating a Window Commnunication Foundation (WCF) service application.

The application needs to service many clients and requests simultaneously.

The application also needs to ensure subsequent individual client requests provide a stateful conversation.

You need to configure the service to support these requirements. Which attribute should you add to the class that is implementing the service?

 

A. [ServiceBehavior(lnstanceContextMode = lnstanceContextMode.PerSession, ConcurrencyMode = ConcurrencyMode.Single)]

B. [ServiceBehavior(lnstanceContextMode = lnstanceContextMode.PerCall, ConcurrencyMode = ConcurrencyMode.Reentrant)]

C. [ServiceBehavior(InstanceContextMode = lnstanceContextMode.PerSession, ConcurrencyMode = ConcurrencyMode.Multiple)]

D. [ServiceBehavior(lnstanceContextMode = lnstanceContextMode.PerCall, ConcurrencyMode = ConcurrencyMode.Multiple)]

 

Correct Answer: C

Explanation/Reference:

many clients and requests simultaneously –> ConcurrencyMode.Multiple requests provide a stateful conversation –> lnstanceContextMode.PerSession

ConcurrencyMode Enumeration

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

InstanceContextMode Enumeration

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

 

 

QUESTION 47

You are integrating a Windows Communication Foundation (WCF) service within an enterprise-wide Service Oriented Architecture (SOA). Your service has the following service contract:

[ServiceContract]public class CreditCardConfirmationService{

[OperationContract]

boolean ConfirmCreditCard(string ccNumber);

 double OrderAmount(int orderNumber);}

You need to allow the code in the ConfirmCreditCard method to participate automatically in existing transactions. If there is no existing transaction, a new transaction must be created automatically. What should you do?

 

A. Inside the ConfirmCreditCard method, surround the code that must participate in the transaction with a using(new TransactionScope()) block.

B. Inside the ConfirmCreditCard method, surround the code that must participate in the transaction with a using(new CommittableTransaction()) block.

C. Add an [OperationBehavior(TransactionScopeRequired=true)] attribute to the ConfirmCreditCard method.

D. Add an [OperationBehavior(TransactionAutoComplete=true)] attribute to the ConfirmCreditCard method.

 

Correct Answer: C

Explanation/Reference:

Set the TransactionScopeRequired to true to require your operation to execute within a transaction scope.

If a flowed transaction is available, the operation executes within that transaction. If one is not available,

a new transaction is created and used for the operation execution. The binding specified in the endpoint controls whether flowed transactions are supported.

Therefore, to obtain the proper behavior you must understand the interaction between whether transaction flow is permitted

by the binding and the TransactionScopeRequired property. The following table shows the possible behavior.

How to: Create a Transactional Service

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

 

 

QUESTION 48

Your Windows Communication Foundation (WCF) client application uses HTTP to communicate with the service.

You need to enable message logging and include all security information such as tokens and nonces in logged messages.

What should you do?

 

A. In the application configuration file, add the IogKnownPii attribute to the message logging diagnostics source and set the value of the attribute to true. Generate the ContosoService class using the Add Service Reference wizard. Add a reference to System.ServiceModel.Routing.dll.

Add the following code segment:

ContosoService client = new ContosoService();

SoapProcessingBehavior behavior = new SoapProcessingBehavior();

behavior.ProcessMessages = true;

client.Endpoint.Behaviors.Add(behavior);

B. In the application configuration file, add the following XML segment to the system.serviceModel configuration section group.

<diagnostics>

<messageLogging LogMessagesAtTransportLevel=”true” LogEntireMessage=”true” />

</diagnostics>

C. In the machine configuration file, add the following XML segment to the system.serviceModel configuration section.

<machineSettings enableLoggingKnownPii=”true” />

Generate the ContosoService class using the Add Service Reference wizard. Add the following code segment.

ContosoService client = new ContosoService();

client.Endpoint.Behaviors.Add(new CallbackDebugBehavior(true));

D. In the machine configuration file, add the following XML segment to the system.serviceModel configuration section.

<machineSettings enableLoggingKnownPii=”true” />

In the application configuration file, add the IogKnownPii attribute to the message logging diagnostics source and set the value of the attribute to true. In the application configuration file, add the following XML segment to the system.serviceModel configuration section group.

<diagnostics>

<messageLogging LogMessagesAtTransportLevel=”true”/>

</diagnostics>

 

Correct Answer: D

Explanation

Explanation/Reference:

Security Concerns for Message Logging

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

By default, keys and personally identifiable information (PII) such as username and password are not logged in traces and logged messages. A machine administrator, however, can use the enableLoggingKnownPII attribute in the machineSettings element of the Machine.config file to permit applications running on the machine to log known personally identifiable information (PII). The following configuration demonstrates how to do this:

<configuration><system.serviceModel><machineSettings enableLoggingKnownPii=”true”/></system.serviceModel></configuration>

An application deployer can then use the logKnownPii attribute in either the App.config or Web.config file to enable PII logging as follows:

<system.diagnostics><sources>

 <source name=”System.ServiceModel.MessageLogging”

logKnownPii=”true”>

<listeners>

 <add name=”messages”

type=”System.Diagnostics.XmlWriterTraceListener”

initializeData=”c:logsmessages.svclog” />

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

Only when both settings are true is PII logging enabled.

The combination of two switches allows the flexibility to log known PII for each application.

PII Logging Configuration

Logging of PII is controlled by two switches: a computer-wide setting found in Machine.config that allows

a computer administrator to permit or deny logging of PII and an application setting that allows an application

administrator to toggle logging of PII for each source in a Web.config or App.config file.

The computer-wide setting is controlled by setting enableLoggingKnownPii to true or false,

in the machineSettings element in Machine.config. For example, the following allows applications to turn on logging of PII.

<configuration><system.serviceModel><machineSettings enableLoggingKnownPii=”true” /></system.serviceModel></configuration>

Note:

The Machine.config file has a default location: %WINDIR%Microsoft.NETFrameworkv2.0.50727CONFIG.

If the enableLoggingKnownPii attribute is not present in Machine.config, logging of PII is not allowed.

Enabling logging of PII for an application is done by setting the logKnownPii attribute of the source element to true or false

in the Web.config or App.config file. For example, the following enables logging of PII for both message logging and trace logging.

<configuration><system.diagnostics><sources>

 <source name=”System.ServiceModel.MessageLogging” logKnownPii=”true”>

<listeners>

</listeners>

</source>

<source name=”System.ServiceModel” switchValue=”Verbose, ActivityTracing”>

<listeners>

 

</listeners>

</source>

</sources></system.diagnostics></configuration>

 

 

QUESTION 49

A Windows Communication Foundation (WCF) service has the following contract.

[ServiceContract(Namespace=”http://contoso.com”)]public interface IShipping{

[OperationContract]string DoWork(int id);}

This is one of several service contracts hosted by your application. All endpoints use SOAP 1.2 bindings with WS-Addressing 1.0.

The System.ServiceModel.MessageLogging trace source in the system.diagnostics configuration section is configured with one listener.

You need to make sure that only the messages that are returned from the DoWork operation are logged.

Which XML segment should you add to the system.serviceModel/diagnostics/messageLogging/filters configuration element?

 

A. <add xmlns:addr=”http://www.w3.org/2005/08/addressing”>/addr:Action[text()=’http://contoso.com/lShipping/DoWorkResponse’] </add>

B. <add xmlns:soap=”http://www.w3.org/2003/05/soap-envelope”>/soap:Action[text()=’http://contoso.com/lShipping/DoWorkResponse’] </add>

C. <add xmlns:addr=”http://www.w3.org/2005/08/addressing”>/addr:Action[text()=`http://contoso.com/lShipping/DoWork’] </add>

D. <add xmlns:soap=”http://www.w3.org/2003/05/soap-envelope”>/soap:Action[text()=`http://contoso.com/lShipping/DoWork’] </add>

 

Correct Answer: A

Explanation/Reference:

 

 

QUESTION 50

You are implementing a Windows Communication Foundation (WCF) service contract named lContosoService in a class named ContosoService.

The service occasionally fails due to an exception being thrown at the service.

You need to send the stack trace of any unhandled exceptions to clients as a fault message. What should you do?

 

A. In the application configuration file on the client, add the following XML segment to the system.serviceModel/behaviors configuration section group.

<endpointBehaviors>

<behavior name=”debug”>

<callbackDebug includeExceptionDetaillnFaults=”true” />

</behavior>

</endpointBehaviors>

Associate the debug behavior with any endpoints that need to return exception details.

B. In the application configuration file on the service and all the clients, add the following XML segment to the system.diagnostics/sources configuration section group.

<source name=”System.ServiceModel” switchValue=”Error” propagateActivty=”true”><listeners>        <add name=”ServiceModelTraceListener” initializeData=”appntracelog.svclog” type=”System.Diagnostics.XmlWriterTraceListener” /></listeners></source>

C. Apply the following attribute to the ContosoService class.

[ServiceBehavior(IncludeExceptionDetailInFaults = true)]

D. For each OperationContract exposed by lContosoService, apply the following attribute.

[FaultContract(typeof(Exception))]

 

Correct Answer: C

Explanation/Reference:ServiceBehaviorAttribute.IncludeExceptionDetailInFaults Property

Gets or sets a value that specifies that general unhandled execution exceptions are to be converted into a System.ServiceModel.FaultException<TDetail> of type System.ServiceModel.ExceptionDetail and sent as a fault message. Set this to true only during development to troubleshoot a service.

 

 

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