none
MessageContract and <s:Body> namespaces RRS feed

  • Question

  • Hi All!

    I'll try to implement MDM service for Windows Phone. 

    In documentation RequestSecurityToken return RequestSecurityTokenResponse with <s:Body> without any namespaces...

    My MessageContract reply:

    <s:Body xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance xmlns:xsd=http://www.w3.org/2001/XMLSchema>
      <RequestSecurityTokenResponseCollection xmlns=http://docs.oasis-open.org/ws-sx/ws-trust/200512>
      ....
      </RequestSecurityTokenResponseCollection>
    </s:Body>


    How i can remove namespaces from Body tag?

    My RequestSecurityTokenCollection:

    [MessageContract]
    [XmlSerializerFormat]
    public class RequestSecurityTokenResponseCollection
    {
        [MessageBodyMember(Namespace = "http://docs.oasis-open.org/ws-sx/ws-trust/200512")]
        [XmlElement(ElementName = "RequestSecurityTokenResponse")]
        public List<RequestSecurityTokenResponse> RequestSecurityTokenResponse { get; set; }
    
        public RequestSecurityTokenResponseCollection()
        {
            this.RequestSecurityTokenResponse = new List<EnrollmentServer.RequestSecurityTokenResponse>();
        }
    }

    May be some custom IDispatchMessageFormatter? But i don't know how to change Body tag..

    Wednesday, September 9, 2015 6:19 AM

Answers

  • Hello Alexey.U,

    Yes, you could create a custom IDispatchMessageFormatter.  As the namespace declarations in the body element actually do not change the meaning of the message this normally is not necessary.  

    This tends to be required when the message is being read by an older service or client that does not read the message as a true XML parser.  I have encountered this when talking to older java services.

    Here are some posts to get you started:

    https://social.msdn.microsoft.com/Forums/vstudio/en-US/3d708665-cb4c-46a0-b512-dbd3edb9a0da/xmlserialiser-in-wcf-does-not-generated-a-namespace-prefix-in-the-generated-xml?forum=wcf

    http://vanacosmin.ro/Articles/Read/WCFEnvelopeNamespacePrefix

    http://stackoverflow.com/questions/14254831/removing-additional-namespace-definition-in-wcf-soap-message


    Jeff

    Wednesday, September 9, 2015 9:32 PM