This blog was in draft from long time (2 more are also waiting) and i am assuming that my readers want to know how to “tamper the soapui request”. It’s just that you have to write few code lines and done.

Create a groovy script test step & paste following code lines :

/*
@Author : Pradeep Bishnoi
@Description : Tampering the soapui request data.
*/
testRequestStep = context.testCase.getTestStepAt(1) //to capture the first test step
testRequest = testRequestStep.getTestRequest()
content = testRequest.getRequestContent()   //getting the request content of the selected test step

// i want to replace the input value 'Bangalore' with 'Jodhpur'
content = content.replaceAll("Bangalore","Jodhpur")
//replacing the original test request content with the modified test request data.
testRequest.setRequestContent(content)

You can also use these code lines in the Event Handlers section of the project & perform the same before submitting the request.

A big Thank You to another open source developer Alex Gorbatchev for developing such a simple yet most powerful utility on the web – SyntaxHighlighter.

P.S. : Now onwards all the code snippets will be shared using Syntax Highlighter which will allow users to directly copy the code lines & paste to run them without any modification.

Till next blog happy tampering with your request data & let the knowledge flow by sharing!!

Advertisements
Comments
  1. YoU.Nike says:

    Ohhh~~Man~ I must say I like your post always. please go ahead~~~
    sorry….I have a question out of scope of your title. please allow me to show that.
    briefly,I have a step using HermesJMS endpoint. that’s OK when I run the test case hit on run button directly. but when I run the test case via test runner,I can see that unknown protocol :jms error in prompt window. would you please advise me how to remove the error? thanks in advance

  2. Hi Aaron,

    No idea about Hermes JMS point in soapUI. Never had an exposure to that technology. Looking forward to some good documentation & sample project to start with 😉
    /Pradeep Bishnoi

  3. YoU.Nike says:

    thanks.
    I just focus on validating if I send message to input queue and then retrieve message from output queue successfully (of course, between input and output, will have some logic to process the message,for example: transform,route,invoke and so on), firstly, I configured Hermes JMS (need third-party jar file,for example: TIBCO EMS, ActiveMQ,Sun MQ…), maybe refer to http://www.soapui.org/JMS/getting-started.html.
    hopefully you can share some related JMS here.

  4. YoU.Nike says:

    Hi Pradeep Bishnoi,
    I’m Aaron, there are 2 questions I need your assistance:
    1. would you please let me know how to get project properties (Not custom properties), for example:Hermes Config, Script Language
    2.where can I modify global property, for example: ${#System#user.home}

    thanks in advance,
    Aaron

  5. priya says:

    Hi Pradeep,
    what if i want to change the parameter/property name itself instead of just its value in the request(to test some bad request behavior).is there a way to do that?specially if the property is being inherited from the resource..?

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s