This is what I've done:
I increase the memory available to Workstation, as your data is large. In Workstation.vmoptions, I add the line
-Xmx2g
I suggest you want to do this in VirtualServiceEnvironment.vmoptions (or VirtualServiceEnvironmentService.vmoptions, if you're running that executable instead) as well
I read your file as input data.
I make some assumptions about the compression involved, and I compress your data in a JSR-223 step like this:
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.zip.GZIPOutputStream;
String str = testExec.getStateValue("requestMessage");
if (str == null || str.length() == 0) {
return str;
}
ByteArrayOutputStream out = new ByteArrayOutputStream();
GZIPOutputStream gzip = new GZIPOutputStream(out);
gzip.write(str.getBytes());
gzip.close();
zipString = out.toString("ISO-8859-1");
zipBytes = out.toByteArray();
testExec.setStateValue("zipString", zipString);
testExec.setStateValue("zipBytes", zipBytes);
return out;
So I now have both a string and a byte array of the data.
I take my suggested Scriptable DPH code from above, add Danny's casting change, and it looks like this:
//byte[] bytemsg=lisa_vse_request.getBodyBytes();
byte[] bytemsg=testExec.getStateValue("zipBytes");
java.util.zip.GZIPInputStream gzin = new java.util.zip.GZIPInputStream(new java.io.ByteArrayInputStream(bytemsg));
java.io.ByteArrayOutputStream byteout = new java.io.ByteArrayOutputStream();
int res = 0;
byte[] buf = new byte[65536]; //if your payload can be more than 64k, increase this
while (res >= 0) {
res = gzin.read(buf, 0, buf.length);
if (res > 0) {
byteout.write(buf, 0, res);
}
}
byte[] uncompressedBytes = byteout.toByteArray();
String uncompressedRequest = new String(uncompressedBytes);
//lisa_vse_request.setBodyText(uncompressedRequest);
return uncompressedRequest;
I run it all as a test. It runs successfully and outputs the same XML as was read in the first step. Therefore the unzip routine is functional, given my assumptions as to how your real data would be compressed.
I decrease the buffer length to 4096, and it appears no make no functional difference, so I leave it like this:
byte[] buf = new byte[4096];
So it looks like it's all working.
Be careful when you copy from the above and paste it into Workstation, because there might be some "browser magic" happening to ruin the result - for example, make sure you overwrite all double-quotes with the " character, in case your browser helpfully converted them to "open-double-quotes" and "close-double-quotes". I've attached my test case if you want to get the scripts from there.
You want to uncomment the two lines in the Scriptable DPH that expect it to be run inside a virtual service, and you want to comment out the "byte[] bytemsg=testExec.getStateValue("zipBytes");" line. You also want to put it all in an "if" statement, so it only runs the routine if your header value is set to "true"
In your stack of data protocol handlers, this scriptable one needs to be before any XML processing.
Finally, you probably want to look at a response-side recording scriptable DPH to do something similar for the response, and then a response-side replay scriptable DPH as an unzip.