PrepAway - Latest Free Exam Questions & Answers

Category: 70-513

Exam 70-513: TS: Windows Communication Foundation Development with Microsoft .NET Framework 4

What should you do?

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?

What are two possible ways to achieve this goal?

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

What are two possble ways to achieve this goal?

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

What should you do?

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?

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?

Which two actions should you perform?

A Windows Communication Foundation (WCF) solution uses the following contract:

[ServiceContract(SessionMode=SessionMode.Allowed)]
public interface IMyService
{
[OperationContract(IsTerminating=false)]
void Initialize();
[OperationContract(IsInitiating=false)]
void DoSomething();
[OperationContract(IsTerminating=true)]
void Terminate();
}

You need to change this interface so that:
* lnitialize is allowed to be called at any time before Terminate is called.
* DoSomething is allowed to be called only after Initialize is called, and not allowed to be called after Terminate is called.
* Terminate will be allowed to be called only after Initalize is called.

Which two actions should you perform? (Each correct answer presents part of the sdution. Choose two)

What should you do?

A Windows Communication Foundation (WCF) solution provides a session-based counter.
The service is self-hosted. The hosting code is as follows:

ServiceHost host = new ServiceHost(typeof(CounterService));
NetTcpBinding binding1 = new NetTcpBinding(SecurityMode.None);
host.AddServiceEndpoint(“MyApplication.ICounterService”, binding1, “net.tcp://localhost:23456”);
host.Open();

This service is currently exposed over TCP, but needs to be exposed to external clients over HTTP.
Therefore, a new service endpoint is created with the following code:

host.AddServiceEndpoint(“MyApplication.ICounterService”, binding2, “http://localhost:12345”);

You need to complete the implementation and ensure that the session-based counter will perform over HTTP as it does over TCP.
What should you do?

What should you do?

A Windows Communication Foundation (WCF) solution uses the following contract to share a message across its clients.
(Line numbers are included for reference only.)

01 [ServiceContract]
02 public interface ITeamMessageService
03 {
04 [OperationContract]
05 string GetMessage();
07 [OperationContract]
08 void PutMessage(string message);
09 }

The code for the service class is as follows:

10 public class TeamMessageService: ITeamMessageService
11 {
12 Guid key = Guid.NewGuid();
13 string message = “Today’s Message”;
14 public string GetMessage()
15 {
16 return stringFormat(“Message:{0} Key:{1}”,
17 message, key);
18 }
19 public void PutMessage(string message)
20 {
21 this.message = message;
22 }
23 }

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

24 ServiceHost host = new ServiceHost(typeof(TeamMessageService));
25 BasicHttpBinding binding = new BasicHttpBinding(BasicHttpSecurityMode.None):
26 host.AddServiceEndpoint(MyApplication.ITeamMessageService, binding, “http://localhost:12345”);
27 host.Open();

You need to ensure that all clients calling GetMessage will retrieve the same string, even if the message is updated by clients calling PutMessage.
What should you do


Page 11 of 15« First...910111213...Last »