Microsoft Exam Questions

Which code segment should you use?

You are developing a Windows Communication Foundation (WCF) service.
The service operation takes a customer number as the only argument and returns information about the customer.
The service requires a security token in the header of the message. You need to create a message contract for the service.
Which code segment should you use?

A.
[ServiceContract]
public interface IService
{
[OperationContract]
CustomerInformation GetCustomerInformation(Header header, int customerNumber);
}
[DataContract]
public class CustomerInformation
{

}
[MessageContract]
public class Header
{
[MessageHeader]
public string SecurityTag;
}

B.
[ServiceContract]
public interface IService
{
[OperationContract]
CustomerInformation GetCustomerInformation(Header header, int customerNumber);
}
[MessageContract]
public class CustomerInformation
{

}
[MessageContract]
public class Header
{
[MessageHeader]
public string SecurityTag;
}

C.
[ServiceContract]
public interface IService
{
[OperationContract]
CustomerInformation GetCustomerInformation(CustomerNumber request);
}
[DataContract]
public class CustomerInformation
{

}
[MessageContract]
public class CustomerNumber
{
[MessageHeader]
public string SecurityTag;
[MessageBodyMember]
public int CustomerNumberElement;
}

D.
[ServiceContract]
public interface IService
{
[OperationContract]
CustomerInformation GetCustomerInformation(CustomerNumber request);
}
[MessageContract]
public class CustomerInformation
{

}
[MessageContract]
public class CustomerNumber
{
[MessageHeader]
public string SecurityTag;
[MessageBodyMember]
public int CustomerNumberElement;
}

Explanation:
Using Message Contracts
(http://msdn.microsoft.com/en-us/library/ms730255.aspx)