Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7855023
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T20:15:30+00:00 2026-06-02T20:15:30+00:00

Here is my code which i wrote in onRequestscript def groovyUtils = new com.eviware.soapui.support.GroovyUtils(context)

  • 0

Here is my code which i wrote in onRequestscript

def groovyUtils = new com.eviware.soapui.support.GroovyUtils(context)
path = "D:\\Service\\something2.xml";
log.info("path = "+ path);
if (mockRequest.method == "POST" )
{
mockRunner.returnFile( mockRequest.httpResponse, new File(path))
return new com.eviware.soapui.impl.wsdl.mock.WsdlMockResult(mockRequest)
}

But this script changes my XML entirely… I want to modify an existing XML(something.xml)..

i was actually Not able to modify the xml so i thought of changinf the xml instead.But according to my business logic its wrong… So can any one help me to modify the xml
in onRequestscript….

XML like

<Something>
    <Data1>
      <value>100</value>
    <Data1>
    <Data2>
      <value>200</value>
    <Data2>
</Something>

to a modified like this

    <Something>
    <Data1>
      <value>101</value>
    <Data1>
    <Data2>
      <value>201</value>
    <Data2>
</Something>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T20:15:33+00:00Added an answer on June 2, 2026 at 8:15 pm

    You can use XmlSlurper to parse and update values from XML file. Then generate a string from updated XML and set it to the response of your mock service.

    I use free SoapUI 3.6.1 but it seems that its output object differs from your example. Revise the code for your needs.

    // get and parse XML file content
    path = "D:\\Service\\something2.xml";
    def doc = new XmlSlurper().parse(path)
    
    // update values
    doc.Data1.value[0] = 101
    doc.Data2.value[0] = 201
    
    // generate and return XML string as service response
    import groovy.xml.StreamingMarkupBuilder
    def result = new StreamingMarkupBuilder().bind{ mkp.yield doc  }.toString()
    mockResponse.setResponseContent(result)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am new to multithreading, and I wrote this code which prints the numbers
Here's a code that I wrote which isn't complete. string line; ifstream fp (foo.txt);
The problem Although the code about which I will talk here I wrote in
Here I wrote code which shows repeated numbers in a text file. Here I
Here is a code which I wrote to test/understand the behavior of pointers of/in
Here is jquery code which hides my table cells with the ID of .style2:
Here is my code which checks if the file exists : #include<stdio.h> #include<zlib.h> #include<unistd.h>
Here is my code which is doing the conversion from hex to decimal. The
I have some code here which works perfectly in firefox but not in chrome
I have this piece of Open MP code here which performs an integeration of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.