PrepAway - Latest Free Exam Questions & Answers

Author: seenagape

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?

What are two possible message exchange patterns that will meet the requirements?

You are designing a Windows Presentation Foundation (WPF) client application that requests reports from a Windows Communication Foundation (WCF) Web service.

Users must be able to perform other tasks while the WCF Web service generates the report.

You need to recommend a message exchange pattern for the communication between the WPF application and the WCF Web service.

What are two possible message exchange patterns that will meet the requirements? (Each correct answer presents a complete solution. Choose two.)

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?

Which class should you use?

You are designing an application by using Microsoft .NET Framework 4 and Microsoft Visual Studio 2010. The application will store data that includes a time and date stamp.

The middle tier of the application is implemented by using Windows Communication Foundation (WCF). The middle tier connects to geographically separated database servers.

You need to ensure that the application meets the following requirements:
Data stored contains time and date information local to the database server.
Data stored contains Universal Coordinated Time (UTC).

Which class should you use?

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

Which location should you recommend?

You are designing a Windows Presentation Foundation (WPF) application. The WPF application contains code that will be executed by both full trust callers and partial trust callers. The WPF application code does not have the AllowPartialTmstCallers attribute set.

You have the following requirements:
The application security settings must allow partial trust callers to create and write to a file. Users must have access only to files that they create and not to files created by other users.

You need to recommend a location for storing each user’ s files.

Which location should you recommend?

What should you do?

You are designing a Windows application by using Microsoft .NET Framework 4 and Microsoft Visual Studio 2010. The business logic layer of the application is implemented by using Windows Communication Foundation (WCF).

You create a duplex bidirectional WCF service that contains a single operation. The service operation sends the result back to the client application by using a two-way callback operation.

You plan to design a service interaction strategy.

You need to ensure that deadlocks are prevented.

What should you do?