PrepAway - Latest Free Exam Questions & Answers

What should you do?

A Windows Communication Foundation (WCF) client and service share the following service contract interface:

[ServiceContract]
public interface IContosoService
{
[OperationContract]
void SavePerson(Person person);
}

They also use the following binding:
NetTcpBinding binding = new NetTcpBinding() { TransactionFlow = true };

The client calls the service with the following code:
using (TransactionScope ts = new TransactionScope(TransactionScopeOption.Required))
{
IContosoService client = factory.CreateChannel();
client.SavePerson(person);
Console.WriteLine(Transaction.Current.TransactionInformation.DistributedIdentifier);
ts.Complete();
}

The service has the following implementation for SavePerson:

public void IContosoService.SavePerson(Person person)
{
person.Save();
Console.WriteLine(Transaction.Current.TransactionInformation.DistributedIdentifier);
}

The distributed identifiers do not match on the client and the server.
You need to ensure that the client and server enlist in the same distributed transaction. What should you do?

PrepAway - Latest Free Exam Questions & Answers

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)]

Explanation:
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 operations 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)

3 Comments on “What should you do?


Leave a Reply