none
Not possible specify a namespace for the nested type in the MessageContract. RRS feed

  • Question

  • Good afternoon.

    Faced with a vexing problem that can not be solved for several days. 

    I need to design a server, given certain requirements. Soap must look a certain way. This is requirement...

    Here is the message that I am able to generate:

    <a:ANotherBool>, <a:AnotherStringValue> - is not correct. Namespace must be  "http_://my.site/rev2015"

    <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
    <s:Header>...</s:Header>
    <s:Body>
    <BoolValue xmlns="http://my.site/rev2015">true</BoolValue>
    <StringValue xmlns="http://my.site/rev2015">HelloWorld</StringValue>
    <InnerType xmlns="http://my.site/rev2015" xmlns:a="http://schemas.datacontract.org/2004/07/Server" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
    <a:ANotherBool>true</a:ANotherBool>
    <a:AnotherStringValue>AnotherHelloWorld</a:AnotherStringValue>
    </InnerType>
    </s:Body></s:Envelope>

    Here is the code that I use.

    [ServiceContract(Namespace = "http://my.site/rev2015")]
    [ServiceKnownType(typeof(InnerType))]
    public interface IService1
    {
        [OperationContract]
        CompositeType GetDataUsingDataContract(CompositeType composite);
    }
    
    [MessageContract(WrapperNamespace = "http://my.site/rev2015", IsWrapped = false)]
    public class CompositeType
    {
        [MessageBodyMember(Namespace = "http://my.site/rev2015")]
        public bool BoolValue;
        [MessageBodyMember(Namespace = "http://my.site/rev2015")]
        public string StringValue;
        [MessageBodyMember(Namespace = "http://my.site/rev2015")]
        public InnerType InnerType;
    }
    
    [MessageContract(WrapperNamespace = "http://my.site/rev2015", IsWrapped = false)]
    public class InnerType
    {
        [MessageBodyMember(Namespace = "http://my.site/rev2015")]
        public bool ANotherBool;
        [MessageBodyMember(Namespace = "http://my.site/rev2015")]
        public string AnotherStringValue;
    }
    
    // impl
    [ServiceBehavior(Namespace = "http://my.site/rev2015")]
    public class Service1 : IService1
    {
        public CompositeType GetDataUsingDataContract(CompositeType composite)
        {...}
    }


    I believe that MessageContract - this is the easiest way to create a desired message type.
    However, if the problem is still not able to resolve - can anyone suggest an alternative solution?

    Wednesday, February 18, 2015 9:57 AM

All replies