You are creating a Windows Communication Foundation (WCF) service that is implemented as follows. (Line numbers are included for reference only.)
01 [ServiceContract]
02 [ServiceBehavior(includeExceptionDetailsInFaults = true)
03 public class OrderService
04 {
05 [Operation Contract]
06 public void Submit Order(Order anOrder)
07 {
08 try
09 {
10 ...
11 }
12 catch(DivideByZeroExcepton ex)
13 {
14
15 }
16 }
17 }
You need to ensure that the stack trace details of the exception are not included in the error information sent to the client.
What should you do?
You are creating a windows Communication Foundation (WCF) service. You do not want to expose the internal implementation at the service layer. You need to expose the following class as a service named Arithmetic with
an operation named Sum
public class Calculator
{
public int Add(int x, nty)
{
}
}
Which code segment should you use?
A Windows Communication Foundation (WCF) application uses a data contract that has several data members. You need the application to throw a SerializationException if any of the data members are not
present when a serialized instance of the data contract is deserialized.
What should you do?
A Windows Communication Foundation (WCF) application uses the following data contract
[DataContract]
public class Person
{
[DataMember]
public string firstName;
[DataMember]
public string lastName;
[DataMember]
public int age;
[DataMember]
public int ID;
}
You need to ensure that the following XML segment is generated when the data contract is serialized. 999999999
The following is an example of a SOAP envelope. 6495 2469
You need to create a message contract that generates the SOAP envelope.
Which code segment should you use?
A class named TestService implements the following interface.
[ServiceContract]
public interface ITestService
{
[OperationContract]
DateTime GetServiceTime();
}
TestService is hosted in an ASP.NET application.
You need to modify the application to allow the GetServiceTime method to return the data formatted as JSON.
It must do this only when the request URL ends in /ServiceTime. What should you do?
A Windows Communication Foundation (WCF) service uses the following service contract.
[ServiceContract]
public interface IService
{
[OperationContract]
string Operation1 (string s);
}
You need to ensure that the operation contract Operation1 responds to HTTP POST requests.
Which code segment should you use?
You are modifying an existing Windows Communication Foundation (WCF) service that is defined as follows
[ServiceContract]
public interface IMessageProcessor
{
[OperationContract]
void ProcessMessages();
public class MessageProcessor: IMessageProcessor
{
public void ProcessMessage();
SubmitOrder();
}
}
SubmitOrder makes a call to another service. The ProcessMessage method does not perform as expected under a heavy load.
You need to enable processing of multiple messages. New messages must only be processed when the
ProcessMessage method is not processing requests, or when it is waiting for calls to SubmitOrder to return.
Which attribute should you apply to the MessageProcessor class?
A Windows Communication Foundation (WCF) service implements the following contract.
[ServiceContract]
public interface IHelloService
{
[OperationContract (WebGet(UriTemplate="hello?name={name}")]
string SayHello(string name);
}
The implementation is as follows:
public class HelloService: IHelloService
{
public string SayHello(string name)
{
return "Hello " + name;
}
}
The service is self-hosted, and the hosting code is as follows:
WebServiceHost svcHost = CreateHost();
svcHost.Open();
Console. ReadLine();
svcHost.Close();
You need to implement CreateHost so that the service has a single endpoint hosted at http://localhost:8000/
HelloService. Which code segment should you use?
You are building a client for a Windows Communication Foundation (WCF) service. You need to create a proxy to consume this service Which class should you use?