Forum Discussion

AnandKiran's avatar
AnandKiran
Frequent Contributor
16 years ago

How to declare Namespaces globally ?

Hi ,

In our project Namespaces are the ones which are bid tricky(i.e they are frequently modified )
. I want to declare them globally for a TestSuite or for a Project .

I am able to achieve the above scenario with the help of groovy script within my testcase , but I have more than 50 testcases. All of a sudden if there is a change in the Namespace I need to manually edit the script for all the testcases.

Can you please suggest me any easy way to solve this issue.

Thanks
With Regards
Anand.

8 Replies

  • AnandKiran's avatar
    AnandKiran
    Frequent Contributor
    Hi ,

    Can you provide any guidance for the above issue . What actually I was following in our script is :

    //define your namespaces
    def ns1='http://RecentCommunicationType/v1'
    def  ns2='http://UserSummary/UpdateRecentCommunicationResponse/v1'
    def ns3 = 'http://Support/Fault/v1'

    response.namespaces["ns1"] = ns1
    response.namespaces["ns2"] = ns2
    response.namespaces["ns3"] = ns3

    I have used theabove lines in one of the TestCase steps for declaring the namespaces. But my question is whether can we declare the same in common for the whole project . Because if we include these lines in every testcase and if there is any change made in the namespace we need to incorporte those changes in every testcase under the project.

    It would be great if you can provide me any solution for this issue .

    Thanks
    With Regards
    Anand
  • AnandKiran's avatar
    AnandKiran
    Frequent Contributor
    Hi ,

    This is very urgent requirement we are planning to promote our customer to use SOAP UI PRO based on this solution. WE have to add some strong points to acheive that so it would be great if any help is provided for this issue.

    Thanks
    Regards
    Anand
  • Hello,

    This should easily be doable using property expansions.
    In your project, add the namespaces as Test Properties (for instance named ns1, ns2 and ns3).
    Replace the script part you posted with the following:


    response.namespaces["ns1"] = context.expand('${#Project#ns1}')
    response.namespaces["ns2"] = context.expand('${#Project#ns2}')
    response.namespaces["ns3"] = context.expand('${#Project#ns3}')


    This way, you just have to change the namespaces in one place, the Project properties.
    Hope this is what you were looking for!

    Regards,
    Dain
    eviware.com
  • AnandKiran's avatar
    AnandKiran
    Frequent Contributor
    Hi Dain,

    Thanks for the idea. But do you mean Global Property ?. In that case I have 10 operations under one WSDL so do I need to declare all the related namespaces for that WSDL in Global Property?

    Thanks
    With Regards
    Anand
  • AnandKiran's avatar
    AnandKiran
    Frequent Contributor
    Hi Dain,

    Thanks I have saved all the name spaces in one txt file. So that i can maintain separately for each project. Thanks for the solution

    Regards
    Anand
  • AnandKiran's avatar
    AnandKiran
    Frequent Contributor
    Hi Dain,

    Is that possible to do the above scenarios using groovy script, just like a setup script (i.e instead of saving the NameSpaces in a separate txt file ).

    1. A Test suite should have a test case with a groovy script which should contain all the Namespaces declared in it

    2. When the test case is executed it should dynamically declare those namespaces globally .

    Is this possible with in SOAP UI


    Thanks
    Regards
    Anand
  • AnandKiran's avatar
    AnandKiran
    Frequent Contributor
    Hi Dain,

    Can you please give me some idea

    Thanks
    Regards
    Anand