none
XML schema validation against WCF request body for request parameter

    Question

  • 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="http://www.w3.org/2005/08/addressing"xmlns:s=""http://www.w3.org/2003/05/soap-envelope"">
    
            <s:Header>
    
            <a:Action s:mustUnderstand=""1"">http://test.com/IGetHeaders/GetHeaders</a:Action>
    
            <a:MessageID>urn:uuid:8ab7081b-9ca8-4948-a192-3565e856792e</a:MessageID>
    
            <a:ReplyTo>
    
              <a:Address>http://www.w3.org/2005/08/addressing/anonymous</a:Address>
    
            </a:ReplyTo>
    
            <a:To s:mustUnderstand=""1"">http://localhost:8731/Design_Time_Addresses/DemoService/HeaderService/</a:To>
    
          </s:Header>
    
          <s:Body>
    
            --Request parameter here, I want to retrieve it, and validate against xml schema from *.xsd file
    
          </s:Body>
    
        </s:Envelope>
    
    

     

    Friday, December 16, 2011 8:40 AM

Answers

  • 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

    Regards

     


    Dennis van de Laar http://www.dennisvandelaar.net
    Friday, December 16, 2011 9:15 AM