This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
I have seen similar error before. It happens when in your code you are accessing a reference of an object returned by the web service framework and while your code manipulates the object the framework closes the stream. It is solved by copying the object data and not using a reference.
In the code you posted I think the problem is in the
try doing a copy of the bytes and then instantiate a string with the local instance and then return the string.