Which code segment should you use?

You are developing a new version of an existing message contract named CustomerDetailsVersion1.
The new version of the message contract must add a Department field of type String to the SOAP header.
You create a new class named CustomerDetailsVersion2 that inherits from CustomerDetailsVersion1.

You need to ensure that all client applications can consume the service. Which code segment should you use?

You are developing a new version of an existing message contract named CustomerDetailsVersion1.
The new version of the message contract must add a Department field of type String to the SOAP header.
You create a new class named CustomerDetailsVersion2 that inherits from CustomerDetailsVersion1.

You need to ensure that all client applications can consume the service. Which code segment should you use?

A.
[MessageContract]
public class CustomerDetailsVersion2 : CustomerDetailsVersion1
{
[MessageHeader(MustUnderstand = false)]
public string Department;
}

B.
public class CustomerDetailsVersion2 : CustomerDetailsVersion1
{
[MessageHeader(MustUnderstand = false)]
public string Department;
}

C.
[MessageContract]
public class CustomerDetailsVersion2 : CustomerDetailsVersion1
{
[MessageHeader(MustUnderstand = true)]
public string Department;
}

D.
public class CustomerDetailsVersion2 : CustomerDetailsVersion1
{
[MessageHeader(MustUnderstand = true)]
public string Department;
}

Explanation:
SoapHeader.MustUnderstand Property
Gets or sets a value indicating whether the SoapHeader must be understood.
true if the XML Web service must properly interpret and process the SoapHeader; otherwise, false. The default is false.

When an XML Web service client adds a SOAP header to an XML Web service method call with the MustUnderstand property set to true,
the XML Web service method must set the DidUnderstand property to true;
otherwise, a SoapHeaderException is thrown back to the XML Web service client by ASP.NET.

Although both the EncodedMustUnderstand and MustUnderstand properties can be used to set the value of the
mustUnderstand attribute within the SOAP header, the MustUnderstand property allows you to set the attribute using a Boolean value.

Data Contract Versioning
(http://msdn.microsoft.com/en-us/library/ms731138%28v=VS.100%29.aspx)

Best Practices: Data Contract Versioning
(http://msdn.microsoft.com/en-us/library/ms733832.aspx)



Leave a Reply 1

Your email address will not be published. Required fields are marked *