Forum Discussion

kishore_konka's avatar
kishore_konka
Occasional Contributor
17 years ago

web service responce valadation againest XSD

HI

How can I validate the responses XML against XSD. I am not having the WSDL URL .I am having only XSD file .

Is it possible give XSD path in  schema compliance Assertion instead of WSDL URL.

If not Possible to give XSD path ,how can we validate the responses XML against XSD.

Please let me know how can I validate the  responses against XSD.

7 Replies

  • kishore_konka's avatar
    kishore_konka
    Occasional Contributor
    Please let me know the sample Groovy script to valadate the Responce xml againest  XSD
  • kishore_konka's avatar
    kishore_konka
    Occasional Contributor
    HI Thanks for suggestion,

    I am not getting the example given at http://www.eviware.com/blogs/oleblog/?p=458 (under "Validation").

    My requirement is to validate the Response XML with XSD(which in turn point other  common XSD's).

    I want  help on

    1) How to refer the XSD( which in turn point other common XSD's) in groovy script.

    2) Response XML comes with SOAP envelop, want to remove the  SOAP Envelop  and validate the response with XSD.

    3) Response  XML contains CDATA, want to remove the CDATA with Groovy script.


    Please help me how to achieve above requirement's with groovy scripting or with the SOAP-UI tool options.
  • kishore_konka's avatar
    kishore_konka
    Occasional Contributor
    HI, Thanks for helping to me.

    By referring the sites you  suggested I had developed the following groovy script to validate the response xml with xsd

    *****Goovy script*****
    def holder = new XmlHolder( messageExchange.responseContentAsXml )
    holder.namespaces["ns1"] = "http://fcubs.iflex.com/FCUBSProcessError"
    def node = holder.getDomNode( "//ns1:FCUBS_RES_ENV[1]" )
    def factory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI)
    def schema = factory.newSchema(new StreamSource(new FileReader("D://New Text Document.xsd")))
    def validator = schema.newValidator()
    validator.validate(new StreamSource(new StringReader(node)))
    ***********

    when I ran the test case I am getting below error meassage.

    groovy.lang.MissingPropertyException: No such property: messageExchange for class: Script15 No such property: messageExchange for class: Script15

    Please let me know how to remove the above error.

    I am pasting my response XML and XSD for yourr reference

    XML:


     
        FLEXCUBE
        FCUBS
        9092520000002805
       
        SAN
        CHO
       
        FCUBSGLService
        QueryChartOfAccounts
       
       
        EXTSYS
        FAILURE
     

     
       
         
            GW-ROUT0005
            User SAN already Logged in FLEXCUBE
         

       

     



    XSD:


    http://www.xmlspy.com)-->









































































  • You will need to access the response in your Groovy TestStep, like this:

    def request = testRunner.testCase.getTestStepByName( "Request 1" );
    def response = request.getProperty( "response" );

    And then use the response to construct the XmlHolder

    /Nenad
    http://eviware.com