PrepAway - Latest Free Exam Questions & Answers

Which service implementation should you use?

You create a Windows Communication Foundation service by using Microsoft .NET Framework 3.5
You write the following code segment.

[ServiceContract(CallbackContract=typeOf(MyServiceCallback))]
public interface IMyService
{
[OperationContract]
void MyMethod();
}
[ServiceContract]
public interface IMyServiceCallback
{
[OperationContract]
void CallbackMethod();
}

The implementation of the MyMethod operation must call back the CallbackMethod operation.
You need to ensure that the service meets the following requirements:
The CallbackMethod operation is able to call the service.
The service instance is thread-safe.
Which service implementation should you use?

PrepAway - Latest Free Exam Questions & Answers

A.
[ServiceBehavior]
public class serviceImpl : MyService
{
public void MyMethod()
{
MyServiceCallback cb = OperationContext.Current.GetCallbackChannel<IMyServiceCallback>()
cb.CallbackMethod();
}
}

B.
[ServiceBehavior(ConcurrencyMode=ConcurrencyMode.Single)]
public class serviceImpl : MyService
{
public void MyMethod()
{
MyServiceCallback cb = OperationContext.Current.GetCallbackChannel<IMyServiceCallback>()
cb.CallbackMethod();
}
}

C.
[ServiceBehavior(ConcurrencyMode=ConcurrencyMode.Multiple)]
public class serviceImpl : MyService
{
public void MyMethod()
{
MyServiceCallback cb = OperationContext.Current.GetCallbackChannel<IMyServiceCallback>()
cb.CallbackMethod();
}
}

D.
[ServiceBehavior(ConcurrencyMode=ConcurrencyMode.Reentrant)]
public class serviceImpl : MyService
{
public void MyMethod()
{
MyServiceCallback cb = OperationContext.Current.GetCallbackChannel<IMyServiceCallback>()
cb.CallbackMethod();
}
}


Leave a Reply