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?
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 serve.r You need to ensure that the client and server enlist in the same distributed transaction. What should you do?
A service implemerts 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?
A Windows Communication Foundation (WCF) service has the following contract:
[ServiceContract]
public class ContosoService
{
[OperationContract]
[TransactionFlow(TransactionFlowOption.Mandatory)]
[OperationBehavior(TransactionScopeRequired=true,
TransactionAutoComplete=false)]
void TxOp 1 (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?
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?
You are integrating a Windows Communication Foundation (WCF) service within an enterprise-wide Service Oriented Architecture (SOA)
Your service has the following service contract.
[ServiceContract]
public class CreditCardConfirmationService
{
[OperationContract]
Boolean ConfirmCreditCard(string cc Number);
double orderAmount, int orderNumber();
}
You need to allow the code in the ConfirmCreditCard method to participate automatically in existing transactions. If there is no existing transaction, a new transaction must be created automatically. What should you do?
Your Windows Communication Foundation (WCF) client application uses HTTP to communicate with the service.
You need to enable message logging and include all security information such as tokens and nonces in logged messages.
What should you do?
A Windows Communication Foundation (WCF) service has the following contract.
[ServiceContract(Namespace="http://contoso.com")]
public interface IShipping
{
[OperationContract]
string DoWork(int id);
}
This is one of several service contracts hosted by your application. All endpoints use SOAP 1.2 bindings with
WS-Addressing 1.0.
The System.ServiceModel.MessageLogging trace source in the system.diagnostics configuration section is configured with one listener. You need to make sure that only the messages that are returned from the DoWork
operation are logged. Which XML segment should you add to the system.serviceModel/diagnostics/ messageLogging/filters configuration element?
You are implementing a Windows Communication Foundation (WCF) service contract named lContosoService in a class named ContosoService.
The service occasionally fails due to an exception being thrown at the service. You need to send the stack trace of any unhandled exceptions to clients as a fault message.
What should you do?
A Windows Communication Foundation (WCF) service is generating a separate namespace declaration for each body member of a message contract, even though all body members share the same namespace.
You need to simplify the XML representation of your message contract so that the namespace is only declared once.
What should you do?