I am trying to access a SOAP service to get data from a URL. I have configured the SOAP service successfully. I am running the following methods for getting response from the SOAP service
soapResponse = soapConnection.call(SoapMsg, endPoint);
soapResponse.writeTo(fileName);
But I get OutOfMemory Exception while getting the response
java.lang.OutOfMemoryError: Java heap space
at java.util.Arrays.copyOf(Arrays.java:3236) ~[na:1.8.0_131]
at java.io.ByteArrayOutputStream.grow(ByteArrayOutputStream.java:118) ~[na:1.8.0_131]
at java.io.ByteArrayOutputStream.ensureCapacity(ByteArrayOutputStream.java:93) ~[na:1.8.0_131]
at java.io.ByteArrayOutputStream.write(ByteArrayOutputStream.java:153) ~[na:1.8.0_131]
at com.sun.xml.internal.messaging.saaj.client.p2p.HttpSOAPConnection.readFully(HttpSOAPConnection.java:553) ~[na:1.8.0_131]
at com.sun.xml.internal.messaging.saaj.client.p2p.HttpSOAPConnection.post(HttpSOAPConnection.java:318) ~[na:1.8.0_131]
at com.sun.xml.internal.messaging.saaj.client.p2p.HttpSOAPConnection.call(HttpSOAPConnection.java:145) ~[na:1.8.0_131]
Hence I want to write to file by breaking the response into smaller chunks before the whole response is retrieved. Any idea how to configure it in this manner?
Thanks in advance.