Hi,

Not sure if you can change your API but when I deal with very large data
sets on SOAP, I pass the data as a string in a single element. The string
is Base64 encoded zip of the original string

My function I use:

public static String zip(String uncompressed) {
        if (uncompressed == null || uncompressed.isEmpty()) {
            return uncompressed;
        }
        GZIPOutputStream gzip = null;
        try {
            ByteArrayOutputStream out = new ByteArrayOutputStream();
            gzip = new GZIPOutputStream(out);
            gzip.write(uncompressed.getBytes());
            gzip.close();
            return new
String(org.apache.commons.codec.binary.Base64.encodeBase64(out.toByteArray()),
"ISO-8859-1");
        } catch (Exception e) {
            myLogger.warn("Error zipping: ", e);
            return "";
        } finally {
            if (gzip != null) {
                try {
                    gzip.close();
                } catch (IOException ex) {
                    myLogger.warn("Error zipping: ", ex);
                }
            }
        }
    }


then on the client:

public static String unzip(String compressed) {
        if (compressed == null || compressed.isEmpty()) {
            return compressed;
        }
        try {
            byte[] b =
org.apache.commons.codec.binary.Base64.decodeBase64(compressed.getBytes("ISO-8859-1"));
            ByteArrayInputStream in = new ByteArrayInputStream(b);
            GZIPInputStream gzip = new GZIPInputStream(in);
            return parseStreamToString(gzip, "ISO-8859-1");
        } catch (Exception e) {
            myLogger.warn("Error unzipping: ", e);
            return "";
        }

    }

public static String parseStreamToString(java.io.InputStream is, String
encoding) throws Exception {
        try {
            return IOUtils.toString(is, encoding);
        } finally {
            is.close();
        }
    }

On 31 March 2017 at 17:11, sscott <ssc...@mapit.net> wrote:

> I am using TomEE-Plume (1.7.2).
>
> I have a Servlet that makes a Service Layer call to an EJB.
> The EJB has a Node (org.w3c.dom.Node) input parameter and a Node output
> Parameter.
> When the dataset is large and contains many elements in the returned Node,
> I
> get a StackOverflowError
> in the Servlet where the Node is returned.
>
> Node outputData = service.serviceRequest(parameters);
>
> What is the best practice to solve this situation?
> Could I use SAX to parse/read the Node (org.w3c.dom.Node) as it is
> received?
> Any pointers or advice are greatly appreciated.
> Thank you.
>
>
>
>
>
> --
> View this message in context: http://tomee-openejb.979440.
> n4.nabble.com/Node-Returned-from-EJB-causes-StackOverflowError-in-Servlet-
> tp4681420.html
> Sent from the TomEE Users mailing list archive at Nabble.com.
>



-- 

*Paul Carter-Brown*

*Group Chief Information Officer*

*Smile Communications Pty (Ltd)       *
Smile +234 (0) 702 000 1234
Mobile +27 (0) 83 4427 179
Skype PaulC-B
paul.carter-br...@smilecoms.com
www.smilecoms.com

-- 


This email is subject to the disclaimer of Smile Communications at 
http://www.smilecoms.com/home/email-disclaimer/ 
<http://www.smilecoms.com/disclaimer>

Reply via email to