views:

24

answers:

0

Given the following service contract:

    [ServiceContract]
    public interface IMyInterface
    {
        [OperationContract(Action = "urn:myns:inputaction", ReplyAction = "urn:myns:replyaction")]
        Reply Method(Request request);
    }

With this message contract (the reply is, as yet, inconsequential):

    [MessageContract(IsWrapped = false)]
    public class Request
    {
        [MessageBodyMember(Namespace = "urn:myns", Order = 0, Name = "MyElement")]
        public XElement TheElement { get; set; }
    }

And the following service implementation:

    public class MyService : IMyInterface
    {
        public Reply Method(Request request)
        {
            request.TheElement.Save(Console.Out);
            return new Reply();
        }
    }

When my service receives a message such as this:

<env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing"&gt;
    <env:Header>
        <wsa:To>http://localhost:8181/&lt;/wsa:To&gt;
        <wsa:Action>urn:myns:inputaction</wsa:Action>
        <wsa:MessageID>uuid:1.2.3.4.5</wsa:MessageID>
        <wsa:ReplyTo>
            <wsa:Address>http://localhost:8080/&lt;/wsa:Address&gt;
        </wsa:ReplyTo>
    </env:Header>
    <env:Body>
        <MyElement xmlns="urn:myns">
            <elem1 attr1="val1" attr2="val2" />
            <elem2 attr3="val3" />
        </MyElement>
    </env:Body>
</env:Envelope>

The method outputs something like this:

<?xml version="1.0" encoding="IBM437"?>
<elem1 attr1="val1" attr2="val2" xmlns="urn:myns" />

My question is, why does the request.TheElement not receive the MyElement element? It seems to me that somehow I'm getting the wrong element in there...