1.
You are developing a Windows Communication Foundation (WCF) service. The service needs to access out-of-process resources. You need to ensure that the service accesses these resources on behalf of the originating caller. What should you do?
2.
A Windows Communication Foundation (WCF) service that handles corporate accounting must be changed to comply with government regulations of auditing and accountability. You need to configure the WCF service to execute under the Windows logged-on identity of the calling application. What should you do?
3.
You have a secured Windows Communication Foundation (WCF) service. You need to track unsuccessful attempts to access the service. What should you do?
4.
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
5.
A Windows Communication Foundation (WCF) solution exposes the following service over a TCP binding. (Line numbers are included for reference only.) 01 [ServiceContract] 02 [ServiceBehavior(ConcurrencyMode = ConcurrencyMode.Multiple)] 03 public class DataAccessService 04 { 05 [OperationContract] 06 public void PutMessage(string message) 07 { 08 MessageDatabase.PutMessage(message); 09 } 10 [OperationContract] 11 pubic string[] SearchMessages(string search) 12 { 13 return MessageDatabase.SearchMessages(search); 14 } 15 } MessageDatabase supports a limited number of concurrent executions of its methods. You need to change the service to allow up to the maximum number of executions of the methods of MessageDatabase. This should be implemented without preventing customers from connecting to the service. What should you do?
6.
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?
7.
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?
8.
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?
9.
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?
10.
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?