Forum Discussion

Jeroen09's avatar
17 years ago

can't get soapUI to save response message using groovy script

I'm trying to get soapUI to save the response I get from a webservice to a file, but somehow I keep getting the same error.

The code I use is as follows:
def FileName = new FileWriter( "d:/out.txt" )
def ResponseMessage = testRunner.testCase.testSteps["Message"].testRequest.response.contentAsString

FileName.printIn( ResponseMessage )


When I run this I get the following error:
groovy.lang.MissingMethodException: No signature of method: java.io.FileWriter.printIn() is applicable for argument types: (java.lang.String) values: {" \r\n  \r\n  \r\n  \r\n   \r\n  \r\n  \r\n  \r\n  \r\n "}


What do I need to do to make this work?

3 Replies

  • omatzura's avatar
    omatzura
    Super Contributor
    Hi!

    try wrapping the FileWriter with a PrintWriter:

    def FileName = new PrintWriter( new FileWriter( "d:/out.txt" ))

    Alternatively just set the dumpFile property (since 2.5) on your request to the desired filename and soapUI will dump the response to that file allowing you to skip the code altogether. You can use property-expansion in this field if you want to control the filename somehow.

    regards!

    /Ole
    eviware.com
  • Hello,

    I am trying to dump my reponse onto the server.
    Is there any way to do so.

    Also When I am setting dumpFile to some location for example c:\filename, I am still getting the response window.
    I don't want the response window asking to save the the file when I am dumping the response via setting the dumpfile property.
  • I am using the XmlHolder object to hold the response content. Then, I print directly it's content in a pretty XML format into a file.


    import com.eviware.soapui.support.XmlHolder

    def response = new XmlHolder(messageExchange.responseContent)
    File responseFile = new File("filename.out")

    responseFile.write(response.prettyXml)


    And it works well.

    Though, I didn't know about the dumpFile property...