XML schema validation against WCF request body for request parameter


  • I have a WCF service method that accepts a parameter. On each request, I have to validate the method parameter to see it contain valid xml contained within the WCF request SOAP body. As I noticed, if the xml is invalid, the method parameter is null. The method parameter is a custom type, which is generated from a *.xsd schema file.


    I have two problems:


    1) How to retrieve the part for the method parameter within the body.


    2) How to perform xml schema validation against the method parameter retrieved from the step 1


    WCF SOAP body request



    <s:Envelope xmlns:a=""xmlns:s="""">
            <a:Action s:mustUnderstand=""1""></a:Action>
            <a:To s:mustUnderstand=""1"">http://localhost:8731/Design_Time_Addresses/DemoService/HeaderService/</a:To>
            --Request parameter here, I want to retrieve it, and validate against xml schema from *.xsd file


    • Edited by Pingpong689 Friday, December 16, 2011 8:55 AM
    Friday, December 16, 2011 8:40 AM


  • Hi,

    parameter inspector could be a solution for you. This way you can validate incoming parameters.

    Take look over here for code how you can validate your xml against a XSD



    Dennis van de Laar
    Friday, December 16, 2011 9:15 AM