Forum Discussion

Michael_Eddingt's avatar
Michael_Eddingt
Occasional Contributor
17 years ago

Set the TestRequest field data source

Hello,

I'm using soapUI Pro.

I'm trying to dynamically set the data source (ala ${DataSource#value}) of fields in a TestRequest via a Groovy script. I'm not sure how to do this. I have looked through the API for WsdlTestRequestStep but didn't see a good way.

A point in the right direction would be great, or some sample Groovy code.

mike

PS- I was asked to repost this to http://www.eviware.com/component/option ... /board,2.0 however I don't have access to that forum.

4 Replies

  • Michael_Eddingt's avatar
    Michael_Eddingt
    Occasional Contributor
    I saw that example which is nice, except I want to dynamically inspect the request to determine what fields are there and assign a datasource property to them.  I'd like the code to work against different operations.

    I had thought about looking at the request xml and searching for the "?" place holder that is put in some fields, but it's not a complete solution.

    I'd also like to avoid re-writing the code in SampleXmlUtil.java that looks to produce the example XML.  Since you are exposing a forms view I was hoping there were already some helper classes someplace that I could use to "easily" inspect the parameters.

    To give a little background on what I'm doing, I would like to run a Groovy script that walks a WsdlProject and creates one or more test suites that performs some standard generic testing of each interface/operation.  This currently includes some basic fuzz testing (throwing random values at each field).

    I already have working code to create the test suite, test cases, etc.  But currently there is a manual step to load each soap request test step and set the property for each field and change the field count in the DataSource code.  I'm hoping to remove that manual step.

    mike
  • omatzura's avatar
    omatzura
    Super Contributor
    Hi Mike,

    sounds like a great feature! If I understand correctly you want to traverse a request and insert property-expansions for each element that should contain data, right?

    Maybe you could use the XmlBeans XmlCursor API for this, it lets you traverse a document pretty easily and modify its contents.. you can get the cursor via the XmlHolder.xmlObject.newCursor() method, then use it as described at http://xmlbeans.apache.org/docs/2.0.0/g ... rsors.html

    Finally, write the updated Request property back with XmlHolder.updateProperty()

    does that sound feasible?

    regards,

    /Ole
    eviware.com
  • Michael_Eddingt's avatar
    Michael_Eddingt
    Occasional Contributor
    Yup, you got it.  I had started looking into the that but was hoping there would be an easier way.

    Guess I will start down that path.

    thanks,
    mike