This is a small change to the original service I've shown. It takes the data to be returned and compresses it into a ZIP stream, which is then returned as a ZIP file attachment.
On line 14 I set compression level to 2, which is quite low but in my limited testing it still gave me a 14:1 compression ratio (on XML data). Having too high a compression level is not worth it in my opinion as that would introduce too much CPU overhead for compression and decompression later.
Something to note is that on line 17 I create a ZIP file entry called mydata.txt, this is the name of the file inside the ZIP that contains the actual data we have compressed. In order to access the data, whatever is calling the web service will have to decompress it.
On lines 19-23 Is where I actually write data to the ZIP file. In this case I am using a OutputStreamWriter to write data to the ZipOutputStream, however any stream could be used here depending on what kind of data you are returning. For example if you are returning marshalled results of your JAXB tree, you can marshall directly to the ZipOutputStream!
This may seem like an awful lot of work so if you are running WebLogic 12.2, you can Enable GZIP Compression for Web Applications instead. This is a transport layer compression so your web service is not aware that it's data is compressed over the network.