Forum Discussion

timmer's avatar
timmer
New Contributor
13 years ago

how to set project propertyValue in RequestFilter Event?

I am trying to set a project level property from inside a RequestFilter.afterRequest Event,
but I don't know how to get to project from either context or request.


// I can do this to expand the property, but I don't know how to set it
def trackingId = context.expand('${#Project#TrackingID}')
// I'd like to do something like
xyz.project.setPropertyValue('TrackingID', someValue)

// from a test i can do something like the following
def trackingId = testRunner.testCase.testSuite.project.getPropertyValue('TrackingId')


Thanks
  • M_McDonald's avatar
    M_McDonald
    Super Contributor
    Same thing except use the context variable

    context.testCase.testSuite.project.setPropertyValue('TrackingID', someValue)
  • timmer's avatar
    timmer
    New Contributor
    M,

    Thanks for you reply, but I was not able to get your solution to work.

    There is no testcase available to this context. I am not sending the request from within
    a TestSuite, TestCase, TestStep ..., though it would be nice to have a generic
    solution that would also work for them.
    As i am new to SoapUI I am not sure what this is called, perhaps A WsdlRequest
    as that is what I got by doing a request.dump().

    Context com.eviware.soapui.impl.wsdl.WsdlSubmitContext
    Request com.eviware.soapui.impl.wsdl.WsdlRequest

    The following works but its ugly and not very generic.
    Is there a better way?

    def project = context.getModelItem().getParent().getInterface().getProject()
    project.setPropertyValue('PROJ_SomeProp', trackingID)


    Thanks,
    Tim
  • M_McDonald's avatar
    M_McDonald
    Super Contributor
    I don't quite understand, where are you sending the request from if not from a test step?
  • timmer's avatar
    timmer
    New Contributor
    M,

    I am new to SoapUI so I don't know the correct name.
    When I add a WSDL to the project it appears on the left hand side of the screen.
    Each msg available for that WSDL appears under it, and I can send a request from there.

    I am using SoapUI to help me determine how one of our vendors WS works, their WS is not very well documented.
    There are no XSDs and the Requests and Responses contain CDATA with embedded XML. There are about 15 WSDLs,
    some have upto 30+ messages, all using embedded CDATA. A few of the 30+msgs are completely generic and
    support another 20+msgs ...

    I do the following:
    1. Run a Testsuite to login and capture the key to a project property.
    2. Send a Request, check the status and capture the TrackingID
    3. Run a Testsuite that sends out some commands, checks the status of the
    project.TrackingId. If ready, get response data, if not loop ...

    Step #2 is not done in a Testsuite because there are just too many commands. Maybe there is a
    better way, but like I said I am a rookie with SoapUI. Manually copying the #2 TrackingId was
    killing me so now I am using the RequestFilter.afterRequest Event.

    Thanks,
    Tim
  • M_McDonald's avatar
    M_McDonald
    Super Contributor
    I'm not terribly clear on what's going on, but for #2, if you created a standalone test case containing the appropriate request test step, you could execute it manually, which would then provide the test case etc. context.