Which code segment should you use?

The following is an example of a SOAP envelope.

<s:Envelope xmlns:s=”http://schemas.xmlsoap.org/soap/envelope”>
<s:Header>
<h:StoreId xmlns:h=”http://www.contoso.com”>6495</h:StoreId>
</s:Header>
<s:Body>
<CheckStockRequest xmlns=”http://www.contoso.com”>
<ItemId>2469<ItemId>
</CheckStockRequest>
</s: Body>
</s:Envelope>

You need to create a message contract that generates the SOAP envelope.
Which code segment should you use?

The following is an example of a SOAP envelope.

<s:Envelope xmlns:s=”http://schemas.xmlsoap.org/soap/envelope”>
<s:Header>
<h:StoreId xmlns:h=”http://www.contoso.com”>6495</h:StoreId>
</s:Header>
<s:Body>
<CheckStockRequest xmlns=”http://www.contoso.com”>
<ItemId>2469<ItemId>
</CheckStockRequest>
</s: Body>
</s:Envelope>

You need to create a message contract that generates the SOAP envelope.
Which code segment should you use?

A.
[MessageContract(WrapperName=”http://www.contoso.com”)]
public class CheckStockRequest
{
[MessageHeader(Namespace=”http://www.contoso.com”)]
public int StoreId { get; set; }
[MessageBodyMember(Namespace=”http://www.contoso.com”)]
public int ItemId { get; set; }
}

B.
[MessageContract(WrapperNamespace=”http://www.contoso.com”)]
public class CheckStockRequest
{
[MessageHeader(Namespace=”http://www.contoso.com”)]
public int StoreId { get; set; }
[MessageBodyMember(Namespace=”http://www contoso.com”)]
public int ItemId { get; set; }
}

C.
[MessageContract(WrapperNamespace=”http://www.contoso.com”)]
public class CheckStockRequest
{
[MessageHeader(Namespace=”http://www.contoso.com”)]
public int StoreId { get; set; }
public int ItemId { get; set; }
}

D.
[MessageContract(WrapperNamespace=”http://www.contoso.com”)]
public class CheckStockRequest
{
[MessageHeader(Namespace=”http://www.contoso.com”)]
public int StoreId { get; set; }
[MessageBodyMember]
public int ItemId { get; set; }
}

Explanation:
MessageContractAttribute.WrapperNamespace Property
(http://msdn.microsoft.com/en-us/library/system.servicemodel.messagecontractattribute.wrappernamespace.aspx)

I saw the answer D!!



Leave a Reply 4

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


John

John

I guess D it’s the right one

John Galt

John Galt

D is the right answer. WrapperNamespace will apply the http://wwww.contoso.com namespace to the wrapper . You don’t want namespace for that’s why B is wrong.