Forum Discussion

Toni's avatar
Toni
New Contributor
17 years ago

Modifying SOAP-Request Data

Hi,
I want to modify some data from a soap-request. How can I do that with groovy. For example.. If I want to set the value of JSESSIONID..  Is there an anorther way to set this value.

Thanks

4 Replies

  • Toni's avatar
    Toni
    New Contributor
    Hi,
    Thanks for Help, Now I can read the necassery value of "JSESSIONID" with this GroovyCode:

    //Reading Cookie
    def state = context.getProperty(com.eviware.soapui.model.testsuite.TestRunContext.HTTP_STATE_PROPERTY )
    assert state != null : "Missing HttpState.."

    def cookies = state.cookies
    assert cookies.length > 0 : "Missing cookies.."

    for( c in 0..cookies.length-1 )
    log.info cookies[c].domain + " " + cookies[c].name + " = " + cookies[c].value


    But how can I set the value of JSESSIONID in the next Soap-Step?
    I found a topic similar to my: http://www.eviware.com/forums/index.php?topic=71.0
    Using the "Maintain HTTP State" option doesn't work in my case.

    I have 2 Flows or Testcases:
    Flow 1: ServerStart // In this Testcase i want to read the JSESSIONID and store it in to a property.
    Flow 2: SeverLogin // In this Testcase i want to set the JSESSIONID using Groovy.

    Now I have a FinalTestcase. I use "Run Testcase Teststep" to combine the 2 Flows. I use a Groovy Step to transfer the property value between the 2 steps.

    Adding a new Cookie in the second Flow with the JSESSIONID doesn't work. The Soap-Step gets always another JSESSIONID.
  • Hello,

    why do not you put in a property , for example if you have property on testsuite level sid

    server start


    // get a propery
    def property = context.testCase.testSuite.properties["sid"]
    property.value = #here get jsession id#



    than in serverlogin you do not need to use groovy just use property expansion.
    in soap request where you have to send jseesionid put ${TestSuite#sid}
    and should be that..

    working?
    robert
  • Toni's avatar
    Toni
    New Contributor
    Hi,
    thanks for the fast reply...
    The property transfer between the flows works fine...
    The mentioned Property "JSESSIONID" is not created by me... I don't know how to access it to set new value. In my first post you can see the mentioned "JSESSIONID" on the picture i want to modify.
    Thanks for help..