Q:

Facing error while sending base64 string in HL7 message over HTTP from android client

I am working with HL7 message in android client (API 17) and using Hapi library to generate and parse HL7 messages.the message is working fine when I am transmitting small string values.
But I have to send an image over Http to the HL7 server and for that I am using MDM_T02 message of HL7 version 2.5. I am getting following error in the server side when I am sending HL7 message with the image converted to Base64 string and inserted into the OBX-5 field.
Jul 23, 2013 3:05:32 PM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet [com.tcs.hl7server.MyServer] in context with path [/MyHL7Server] threw exception
java.lang.ArrayIndexOutOfBoundsException
    at java.lang.System.arraycopy(Native Method)
    at org.apache.tomcat.util.buf.ByteChunk.substract(ByteChunk.java:441)
    at org.apache.catalina.connector.InputBuffer.read(InputBuffer.java:315)
    at org.apache.catalina.connector.CoyoteInputStream.read(CoyoteInputStream.java:200)
    at ca.uhn.hl7v2.hoh.encoder.AbstractHl7OverHttpDecoder.readBytesNonChunked(AbstractHl7OverHttpDecoder.java:370)
    at ca.uhn.hl7v2.hoh.encoder.AbstractHl7OverHttpDecoder.doReadContentsFromInputStreamAndDecode(AbstractHl7OverHttpDecoder.java:191)
    at ca.uhn.hl7v2.hoh.encoder.AbstractHl7OverHttpDecoder.readContentsFromInputStreamAndDecode(AbstractHl7OverHttpDecoder.java:421)
    at ca.uhn.hl7v2.hoh.raw.server.HohRawServlet.doPost(HohRawServlet.java:68)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:647)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
    at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:936)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
    at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1004)
    at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589)
    at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:310)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
    at java.lang.Thread.run(Thread.java:722)

I am not getting why thr ByteChunk.java is giving error.
It will be highly appreciated if anyone can throw some light on this.
Thanks.

A:

The problem was in handing HTTPServletRequest in the server side using the HAPI provided API as the maximum size of the buffer in HAPI classes are capped to 4kB.In this case the HL7 message is having a Base 64 String payload of 20-30 kB. This problem was solved when the incoming HTTPServletRequest was handled in a separate doPost method and HL7 message was created from the incoming data.

