Latest MCTS 70-513 Dumps Real Exam Download 131-140

Ensurepass

QUESTION 131

You are developing a Windows Communication Foundation (WCF) service.

You enable message logging, trace listeners, activity propagation, and tracing on the trace sources.

You have the following code segment in the client application. (Line numbers are included for reference only.)

01 Guid multiCallActivityId = Guid.NewGuid();02 TraceSource ts = new TraceSource(“Multicall”);03 Trace.CorrelationManager.ActivityId = multiCallActivityId;04

You encounter errors when your client application consumes the service.

You need to ensure that your client application can correlate tracing information with the service.

Which code segment should you add at line 04?

 

A.            ts.TraceEvent(TraceEvencType.Start, 0, “Calling first service”);ts.TraceTransfer(100, “Transferring…”, multiCallActivityId); … ts.TraceEvent(TraceEventType.Stop, 0, “Return from first service.”);

B.            Trace.CorrelationManager.StartLogicalOperation(“1”); … Trace.CorrelationManager.StopLogicalOperation();

C.            ts.TraceEvent(TraceEventType.Start, 0, “Calling first service”);ts.TraceTransfer(100, “Transferring…”, Guid.NewGuid()); … ts.TraceEvent(TraceEventType.Stop, 0, “Return from first service.”);

D.            ts.TraceEvent(TraceEventType.Start, 0, “Calling first service”);Trace.CorrelationManager.StartLogicalOperation(“1”); … ts.TraceEvent(TraceEventType.Stop, 0, “Return from first service.”);

 

Correct Answer: C

Explanation/Reference:

Propagating the Activity ID to A Service

When the activity ID is propagated across endpoints, the message receiver emits a Start and Stop traces

with that (propagated) activity ID. Therefore, there is a Start and Stop trace with that gAId from each trace source.

If the endpoints are in the same process and use the same trace source name, multiple Start and Stop with

the same lAId (same gAId, same trace source, same process) are created.

If you set the propagateActivity attribute to true for the System.ServiceModel trace source in both the client

and service configuration files, the service processing for the Add request occurs in the same activity as the one defined in the client.

If the service defines its own activities and transfers, the service traces do not appear in the client-propagated activity.

Instead, they appear in an activity correlated by transfer traces to the activity whose ID is propagated by the client.

Note:

If the propagateActivity attribute is set to true on both the client and service, the ambient activity in the operation scope of the service is set by WCF.

You can use the following code to check whether an activity was set in scope by WCF.

// Check if an activity was set in scope by WCF, i.e., if it was// propagated from the client. If not, i.e., ambient activity is// equal to Guid.Empty, create a new one.if(Trace.CorrelationManager.ActivityId == Guid.Empty){

 Guid newGuid = Guid.NewGuid();

Trace.CorrelationManager.ActivityId = newGuid;}// Emit your Start trace.ts.TraceEvent(TraceEventType.Start, 0, “Add Activity”);

// Emit the processing traces for that request.

serviceTs.TraceInformation(“Service receives Add ” + n1 + “, ” + n2);

// double result = n1 + n2;

serviceTs.TraceInformation(“Service sends Add result” + result);

// Emit the Stop trace and exit the method scope.

ts.TraceEvent(TraceEventType.Stop, 0, “Add Activity”);

// return result;

Emitting User-Code Traces

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

Tracing and Message Logging

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

Propagation

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

Service Trace Viewer Tool (SvcTraceViewer.exe)

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

 

 

QUESTION 132

You are developing a Windows Communication Foundation (WCF) service. One of the service operations contains the following code.

private static int counter = 0;

[OperationContract]

public void IncrementCount()

{

 counter++;}

You need to set a service behavior that prevents two or more threads from incrementing the counter variable at the same time. Which code segment should you use to set the service behavior?

 

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

B. [ServiceBehavior(InstanceContextMode = InstanceContextMode.PerSession, ConcurrencyMode = ConcurrencyMode.Single)]

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

D. [ServiceBehavior(InstanceContextMode = InstanceContextMode.PerCall, ConcurrencyMode = ConcurrencyMode.Reentrant)]

 

Correct Answer: A

Explanation/Reference:

“prevents two or more threads…at the same time” –> ConcurrencyMode.Single

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 133

clip_image002

A. Use basicHttpBinding for both the client application and the service.

B. Create the persistence provider database and configure the persistenceProvider element of the service behavior to point to that database.

C. Use wsHttpContextBinding for both the client application and the service.

D. In the method to add an item to the shopping cart, serialize the shopping cart contents after adding the current item and storing it in a Session variable.

 

Correct Answer: BC

Explanation/Reference:

Durable services are Windows Communication Foundation (WCF) services that use context bindings, attributes,

and new configuration elements to persist service state information to a store, such as a SQL database,

which means that durable services have the capability to restore their own state when they are recycled.

Durable services are useful when implementing long-running stateful conversations.

Durable services are Windows Communication Foundation (WCF) services that are designed to be durable and long-running,

and to survive application and server restarts. Durable services are persisted using either the out-of-the-box provider created by

a SqlPersistenceProviderFactory or a custom persistence provider derived from the abstract class PersistenceProvider or LockingPersistenceProvider.

Caution:

To use SqlPersistenceProviderFactory, create your persistence database using the scripts from .NET Framework 3.0.

These scripts install by default to the C:WindowsMicrosoft.NETFrameworkv3.0Windows Workflow FoundationSQLEN*.sql directory.

Tutorial: Create a Durable Service

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

 

 

QUESTION 134

A Windows Communication Foundation (WCF) service is deployed with netTcpBinding.

This service uses a duplex message exchange pattern.You are developing the next version of the WCF service.

You discover that your company’s hardware load balancer performs correctly only for WCF services that use HTTP.

You need to ensure that your service works with the load balancer. What should you do?

 

A. Use basicHttpBinding.

B. Create a custom binding that has the compositeDuplex, textMessageEncoding, and namedPipeTransport binding elements in this order.

C. Create a custom binding that has the compositeDuplex, textMessageEncoding, and wsHttpTransport binding elements in this order.

D. Use wsHttpBinding.

 

Correct Answer: CExplanation/Reference:Custom Bindings

You can add binding elements by adding the desired BindingElement objects to its Elements collection.

The order in which the binding element is added is very important. The order of adding the binding elements is as follows:

1.

Transaction Flow (not required)

2.

Reliable Messaging (not required)

3.

Message Security (not required)

4.

Composite Duplex (not required)

5.

Message Encoding (required)

6.

Transport Security (not required)

7.

Transport (required)

Bindings

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

WCF Bindings in Depth

(http://msdn.microsoft.com/en-us/magazine/cc163394.aspx)

 

 

QUESTION 135

You are developing a Windows Communication Foundation (WCF) service that executes a long-running operation. The service is accessed from your business applications in a server transaction in which the client does not participate. You need to ensure that the transaction times out and aborts if the operation has not completed within 45 seconds. What should you do?

 

A. Set the service binding sendTimeout attribute to 00:00:45.

B. Apply [ServiceBehavior(TransactionTimeout=”00:00:45″)] to the service implementation.

C. Set the service binding receiveTimeout attribute to 00:00:45.

D. Apply [OperationBehavior(TransactionScopeRequired=false)] to the service operation.

 

Correct Answer: B

Explanation/Reference:ServiceBehaviorAttribute.TransactionTimeout Property

Gets or sets the period within which a transaction must complete.

ServiceBehaviorAttribute.TransactionTimeout Property

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

 

 

QUESTION 136

You are developing a Windows Service. The Windows Service will host a Windows Communication Foundation (WCF) service.

The Windows Service class will inherit from ServiceBase.

You need to ensure that the WCF service starts when the Windows Service is restarted. What should you do in the Windows Service class?

 

A. – Create a public method named Main.

-Create a new ServiceHost in the Main method.

-Override the OnShutdown method and close the ServiceHost.

B. – Override the OnStart method and create and open a new ServiceHost.

-Override the OnStop method and close the ServiceHost.

C. – Override the OnPowerEvent method and open a new ServiceHost.

-Override the OnShutdown method and close the ServiceHost.

D. – Override the OnContinue method and open a new ServiceHost.

-Override the OnStop method and close the ServiceHost.

 

Correct Answer: B

Explanation/Reference:

Windows services can be managed with the Microsoft.ManagementConsole.SnapIn in Microsoft Management Console (MMC)

and can be configured to start up automatically when the system boots up.

This hosting option consists of registering the application domain (AppDomain) that hosts a WCF service as a managed

Windows service so that the process lifetime of the service is controlled by the Service Control Manager (SCM) for Windows services.

The service code includes a service implementation of the service contract, a Windows Service class, and an installer class.

The service implementation class, CalculatorService, is a WCF service. The CalculatorWindowsService is a Windows service.

To qualify as a Windows service, the class inherits from ServiceBase and implements the OnStart and OnStop methods.

In OnStart, a ServiceHost is created for the CalculatorService type and opened. In OnStop, the service is stopped and disposed.

The host is also responsible for providing a base address to the service host, which has been configured in application settings.

The installer class, which inherits from Installer, allows the program to be installed as a Windows service by the Installutil.exe tool.

 

 

QUESTION 137

You are developing a Windows Communication Foundation (WCF) service to provide an in-memory cache for many Web applications. The service contract is defined as follows. (Line numbers are included for reference only.)

01 [ServiceContract]

02 public interface IDataCache

03 {

04 …

05 }

06

07

08 public class DataCache : IDataCache

09 {

10 …

11 }

You need to ensure that all users share the cache. Which code segment should you insert at line 07?

 

A. [ServiceBehavior(TransactionIsolationLevel = IsolationLevel.RepeatableRead)]

B. [ServiceBehavior(InstanceContextMode = InstanceContextMode.Single)]

C. [ServiceBehavior(InstanceContextMode = InstanceContextMode.PerSession)]

D. [ServiceBehavior(TransactionIsolationLevel = IsolationLevel.ReadComitted)]

 

Correct Answer: B

Explanation/Reference:InstanceContextMode Enumeration

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

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.

 

 

QUESTION 138

You develop a Windows Communication Foundation (WCF) service that uses basic authentication for client credentials.

This service is currently configured to use message security. The service is hosted on a server in workgroup mode.

Users report that their passwords are stolen when they use public computers.

You need to ensure that messages are secure and users are authenticated.

You prevent the service from being called over HTTP through Microsoft Internet Information Services (IIS) configuration.

What should you do next?

 

A. Use the transport security mode and specify None for transport client credential type.

B. Use the transportWithMessageCredential security mode and specify Basic for the transport client credential type.

C. Use the message security mode and specify Basic for the transport client credential type.

D. Use the transportWithMessageCredential security mode and specify None for the transport client credential type.

 

Correct Answer: B

Explanation/Reference:

By default, the wsHttpBinding binding provides HTTP communication. When configured for transport security, the binding supports HTTPS communication. HTTPS provides confidentiality and integrity protection for the messages that are transmitted over the wire. However the set of authentication mechanisms that can be used to authenticate the client to the service is limited to what the HTTPS transport supports. Windows Communication Foundation (WCF) offers a TransportWithMessageCredential security mode that is designed to overcome this limitation.

When this security mode is configured, the transport security is used to provide confidentiality and integrity for the transmitted messages and to perform the service authentication. However, the client authentication is performed by putting the client credential directly in the message. This allows you to use any credential type that is supported by the message security mode for the client authentication while keeping the performance benefit of transport security mode.

 

 

QUESTION 139

You are developing a Windows Communication Foundation (WCF) service. One of the parameters used with the

service operations is a security token. The security token is not sensitive.

The monitoring software tracks security tokens and can read tokens in clear text only.

The company security policy requires that you validate all clear text data passed over the corporate network.

You need to ensure that the service verifies that the security token is not changed during transit. What should you do?

 

A. For all the security-sensitive members, set the ProtectionLevel parameter of the MessageBodyMember or MessageHeader attribute to EncryptAndSign.

B. Implement IEndpointldentityProvider in the message contract class.

C. Implement ISecureConversationSession in the message contract class.

D. For all the security-sensitive members, set the ProtectionLevel parameter of the MessageBodyMember or MessageHeader attribute to Sign.

 

Correct Answer: D

Explanation/Reference:

“can read tokens in clear text only” + ” verifies that …is not changed during transit” –> ProtectionLevel.Sign

To understand the protection level feature, the following basic statements apply:

Three basic levels of protection exist for any part of a message. The property (wherever it occurs) is set to

one of the ProtectionLevel enumeration values. In ascending order of protection, they include:

None.

Sign. The protected part is digitally signed. This ensures detection of any tampering with the protected message part.

EncryptAndSign. The message part is encrypted to ensure confidentiality before it is signed.

How to set ProtectionLevel Property

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

 

 

QUESTION 140

You are developing a Windows Communication Foundation (WCF) service.

The following code defines and implements the service. (Line numbers are included for reference only.)

01 [ServiceContract(SessionMode = SessionMode.Allowed)]

02 public interface ICatchAll

03 {

04 [OperationContract(IsOneWay = false, Action = “*”, ReplyAction = “*”)]

05 Message ProcessMessage(Message message);

06 }

07

08 public class CatchAllService : ICatchAll

09 {

10 public Message ProcessMessage(Message message)

11 12  { 

13   

14 15 16  }  }  return returnMsg; 

You need to ensure that two identical copies of the received message are created in the service. Which code segment should you insert at line 12?

 

A.            Message msgCopy = message.CreateBufferedCopy(8192) as Message;Message returnMsg = message.CreateBufferedCopy(8192) as Message;

B.            MessageBuffer buffer = message.CreateBufferedCopy(8192);Message msgCopy = buffer.CreateMessage();Message returnMsg = buffer.CreateMessage();

C.            MessageBuffer buffer = message.CreateBufferedCopy(8192);Message msgCopy = buffer.CreateMessage();Message returnMsg = msgCopy;

D.            Message msgCopy = message;Message returnMsg = message;

 

Correct Answer: B

Explanation/Reference:MessageBuffer Class

Represents a memory buffer that stores an entire message for future consumption.

MessageBuffer.CreateMessage Method

Returns a copy of the original message.

MessageBuffer Class

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

 

 

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