Forum Discussion

Konda_R's avatar
Konda_R
Occasional Contributor
16 years ago

How to make namespace URIs associated with prefix dynamic in response assertions

Hi
I am using soapUI Pro 3.0.1 licensed edition & would like to make the namespace URIs referenced by the namespace prefix in the test assertions dynamic so that the response assertions wont fail.
For example please find bellow the Xpath Match failure message.
The test case works fine when executed on the machine where soapUI tests are created & web service is hosted.
But when I execute this test case after deploying the test suites & webservice on to a different server and specifying the new end point ,I am getting the bellow Xpath match failure.
[XPath Match] XPathContains assertion failed for path
[declare namespace ser-root='http://${server1}/prov/soap12doclit/Pwsd_docRefList';
//ser-root:docRefListResponse[1]] : Exception:org.custommonkey.xmlunit.Diff
[different] Expected namespace URI 'http://server1/prov/soap12doclit/Pwsd_docRefList' but was 'http://server2/prov/soap12doclit/Pwsd_docRefList' - comparing at /docRefListResponse[1] to at /docRefListResponse[1]


That is, when creating tests on sever1,the namespace URI associated with prefixs 'pwsd' in request message & 'ser-root' in resposne message is http://server1/prov/soap12doclit/Pwsd_docRefList.

But after deploying the tests & web service onto different server 'server2',the namespace URIs associated with prefixs 'pwsd' in request message is http://server1/prov/soap12doclit/Pwsd_docRefList & 'ser-root' in resposne message is http://server2/prov/soap12doclit/Pwsd_docRefList which is why the above Xpath match is failing.

Please note that I am deploying all the webservices on server2 before running tests from an ANT target using exec command from server2.The following is the exact request response messages sent & received on server2:

----------------- Properties ------------------------------
Encoding: UTF-8
Password: x
Username: y
Endpoint: http://server2:2040/ws/prov_soap12rpcli ... RefList_21

---------------- Request ---------------------------


 

 
     
       
           
           
              s
           

       

     

 


---------------- Response --------------------------


 

 
     
       
           
             
                  outStr1
             

           

           
             
                  outStr2
             

           

           
             
                  outStr3
             

           

       

     

 



Eventhough the test case returns expected reposne XML ,the test fails at validating the namespace URI referenced by prefixs used in the response assertions.

I tried using property expansions in response assertion & as well as in expected result something like:

Assertion:

declare namespace ser-root='http://${hostname}/prov/soap12doclit/Pwsd_docRefList';
//ser-root:docRefListResponse[1]

Expected Result:


           
               
                  outStr1
               

           

           
               
                  outStr2
               

           

           
               
                  outStr3
               

           

       



Could you suggest me how to fix this problem.

Thanks
Kondareddy

1 Reply

  • Konda_R's avatar
    Konda_R
    Occasional Contributor
    Hi

    I found a way to make namespace URI dynamic in request/response assertions.
    Since the WSDL's are genrated on the fly evreytime you run the tests on a specified server ,the namespaces are also changing according to the server name.But the NS URIs in my test case requests are hardcoded .Hence the Xpath assrtion failures.

    Now I made the NS URIs for all test case requests generic using the property expansion.For Ex:


     

     
         
            file:C:\HTTPTest\WmPublicNew.txt
            file:C:\HTTPTest\xalan.jar