2015-01-16 3 views
1

Это ясно how to save отклик содержание от soapui. Но в моем случае содержимое ответа сохраняется в формате gzip, поэтому содержимое файла должно быть «ungzipped» для чтения. Возможно ли разблокировать ответ в soapui во время сохранения?Как сохранить сжатый ответ от soapui?

ответ

1

Я думаю, что это невозможно сделать с помощью SOAPUI вариантов. Однако вы можете сделать это с отличным сценарием.

Добавить groovy testStep после testStep Запрос, который сохраняет ваш ответ на Dump File. В этом groovy testStep добавить последующий код, распаковать свой ответ и сохранить результат в том же пути ваш Dump File, вы только указать Dump File имя и каталог в порядок groovy сценарий может распаковать его:

import java.io.ByteArrayInputStream 
import java.io.FileOutputStream 
import java.io.IOException 
import java.util.zip.ZipEntry 
import java.util.zip.ZipInputStream 

def buffer = new byte[1024] 

// create the zip input stream from your dump file 
def dumpFilePath = "C:/dumpPath/" 
FileInputStream fis = new FileInputStream(dumpFilePath + "dumpFile.zip") 
def zis = new ZipInputStream(fis) 
def zip = null 

// get each entry on the zip file 
while ((zip = zis.getNextEntry()) != null) { 

    // decompile each entry 
    log.info("Unzip entry here: " + dumpFilePath + zip.getName()) 
    // create the file output stream to write the unziped content 
    def fos = new FileOutputStream(dumpFilePath + zip.getName()) 
    // read the data and write it in the output stream 
    int len; 
    while ((len = zis.read(buffer)) > 0) { 
     fos.write(buffer, 0, len) 
    } 

    // close the output stream 
    fos.close(); 
    // close entry 
    zis.closeEntry() 
} 

// close the zip input stream 
zis.close() 

Я прочитал еще раз свой вопрос, и я понимаю, что вы хотите, чтобы ungzip не распаковать поэтому, возможно, вы можете использовать этот заводной код вместо:

import java.io.ByteArrayInputStream 
import java.io.FileOutputStream 
import java.io.IOException 
import java.util.zip.GZIPInputStream 

def buffer = new byte[1024] 

// create the zip input stream from your dump file 
def dumpFilePath = "C:/dumpPath/" 
FileInputStream fis = new FileInputStream(dumpFilePath + "dumpFile.gz") 
// create the instance to ungzip 
def gzis = new GZIPInputStream(fis) 
// fileOutputStream for the result 
def fos = new FileOutputStream(dumpFilePath + "ungzip") 
// decompress content 
gzis.eachByte(1024){ buf, len -> fos.write(buf,0,len)} 
// close streams 
gzis.close(); 
fos.close(); 

Надеется, что это помогает,

Смежные вопросы