title: Unexpected EOF in prolog
body: <p>On client side I created 3 attachments in the following way:</p>
  
  <pre><code>public String sendMessage(MMSMessage mmsMessage, String formatCDR, FlowSessionData flowSessionData)
          throws IOException, ServiceException, PolicyException {
  
      SendMessage sendMessage = sendMessageService.getSendMessage();
      int index = 1;
      List&lt;Attachment&gt; atts = new ArrayList&lt;Attachment&gt;();
      BufferedImage image =  ImageIO.read(new URL(mmsMessage.getImgPath()));
      atts.add(createAttachmentPart(mmsMessage.getImgMimeType(), image, index));
      if (mmsMessage.getPrerollText() != null) {
          atts.add(createAttachmentPart("text/plain", mmsMessage.getPrerollText(), index++));
      }
      if (mmsMessage.getPostrollText() != null) {
          atts.add(createAttachmentPart("text/plain", mmsMessage.getPostrollText(), index++));
      }
      setServiceParams((BindingProvider) sendMessage, atts, configService.getSendMessageEndpointAddress());
      String value = null;
      validateURI(configService.getParlayxCallbackEndpointService() + "/" + NOTOFICATION_MMS_INTERFACE);
      SimpleReference correlator = new SimpleReference();
      correlator.setCorrelator(formatCDR);
      correlator.setInterfaceName(NOTOFICATION_MMS_INTERFACE);
      correlator.setEndpoint(configService.getParlayxCallbackEndpointService() + "/" + NOTOFICATION_MMS_INTERFACE);
      String toNumber = mmsMessage.getSmsServiceActivationNumber().get(0);
      if (!toNumber.startsWith(MSGConstants.PHONE_URI_PREFIX)) {
          if (!toNumber.startsWith("+")) {
              toNumber = "+" + toNumber;
          }
          toNumber = MSGConstants.PHONE_URI_PREFIX + toNumber;
      }
      validateURI(toNumber);
      List&lt;String&gt; addr = new ArrayList&lt;String&gt;();
      addr.add(toNumber);
      value = sendMessage.sendMessage(addr, mmsMessage.getSenderAddress(), mmsMessage.getSubject(), null, null,
              correlator);
      LOGGER.info(value);
      return value;
  }
  
  private Attachment createAttachmentPart(String mimeType, Object data, int index) {
          return new AttachmentImpl(String.valueOf(index), new DataHandler(data, mimeType));
      }
  
  private void setServiceParams(BindingProvider serviceInf, Collection&lt;Attachment&gt; attachments, String endPoint) {
          Map&lt;String, Object&gt; requestContext = serviceInf.getRequestContext();
          requestContext.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, endPoint);
          requestContext.put(BindingProvider.USERNAME_PROPERTY, configService.getParlayxEndPointUserName());
          requestContext.put(BindingProvider.PASSWORD_PROPERTY, configService.getParlayxEndPointPassword());
          final Client client = ClientProxy.getClient(serviceInf);
          final HTTPConduit http = (HTTPConduit) client.getConduit();
          final HTTPClientPolicy httpClientPolicy = new HTTPClientPolicy();
          httpClientPolicy.setReceiveTimeout(configService.getParlayxEndPointTimeOut());
          httpClientPolicy.setAllowChunking(false);
          httpClientPolicy.setConnectionTimeout(configService.getParlayxEndPointTimeOut());
          http.setClient(httpClientPolicy);
          if (attachments != null &amp;&amp; !attachments.isEmpty()) {
              requestContext.put(org.apache.cxf.message.Message.ATTACHMENTS, attachments);
          }
      }
  </code></pre>
  
  <p>And I receive the exception below, what causes it and how can I fix it?</p>
  
  <blockquote>
    <p>WARNING: Interceptor for
    {http://www.csapi.org/wsdl/parlayx/multimedia_messaging/send/v2_4/service}SendMessageService#{http://www.csapi.org/wsdl/parlayx/multimedia_messaging/send/v2_4/interface}sendMessage
    has thrown exception, unwinding now
    org.apache.cxf.binding.soap.SoapFault:
    Error reading XMLStreamReader.    at
    org.apache.cxf.binding.soap.interceptor.ReadHeadersInterceptor.handleMessage(ReadHeadersInterceptor.java:222)
      at
    org.apache.cxf.binding.soap.interceptor.ReadHeadersInterceptor.handleMessage(ReadHeadersInterceptor.java:60)
      at
    org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:255)
      at
    org.apache.cxf.endpoint.ClientImpl.onMessage(ClientImpl.java:755)
      at
    org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponseInternal(HTTPConduit.java:2335)
      at
    org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponse(HTTPConduit.java:2193)
      at
    org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.close(HTTPConduit.java:2037)
      at
    org.apache.cxf.transport.AbstractConduit.close(AbstractConduit.java:56)
      at
    org.apache.cxf.transport.http.HTTPConduit.close(HTTPConduit.java:697)
      at
    org.apache.cxf.interceptor.MessageSenderInterceptor$MessageSenderEndingInterceptor.handleMessage(MessageSenderInterceptor.java:62)
      at
    org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:255)
      at
    org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:516)
      at
    org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:313)
      at
    org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:265)
      at
    org.apache.cxf.frontend.ClientProxy.invokeSync(ClientProxy.java:73)
      at
    org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:124)
      at $Proxy92.sendMessage(Unknown
    Source)   at
    com.amobee.common.sms.ParlayxMessagingService.sendMessage(ParlayxMessagingService.java:105)
      at
    com.amobee.nc.protocol.msg.MMSResponseBuilder.buildResponseMessage(MMSResponseBuilder.java:96)
      at
    com.amobee.nc.protocol.msg.BaseMSGResponseWriter.getResponse(BaseMSGResponseWriter.java:59)
      at
    com.amobee.nc.protocol.AbstractResponseWriter.write(AbstractResponseWriter.java:75)
      at
    com.amobee.frontend.servlets.AbstractBaseServlet.runCommand(AbstractBaseServlet.java:124)
      at
    com.amobee.frontend.servlets.AbstractBaseServlet.doGet(AbstractBaseServlet.java:64)
      at
    javax.servlet.http.HttpServlet.service(HttpServlet.java:575)
      at
    javax.servlet.http.HttpServlet.service(HttpServlet.java:668)
      at
    org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:511)
      at
    org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:390)
      at
    org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
      at
    org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)
      at
    org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
      at
    org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:418)
      at
    org.mortbay.jetty.handler.HandlerCollection.handle(HandlerCollection.java:114)
      at
    org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
      at
    org.mortbay.jetty.Server.handle(Server.java:326)
      at
    org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
      at
    org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:923)
      at
    org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:547)
      at
    org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:212)
      at
    org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
      at
    org.mortbay.jetty.bio.SocketConnector$Connection.run(SocketConnector.java:228)
      at
    org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:582)
    Caused by:
    com.ctc.wstx.exc.WstxEOFException:
    Unexpected EOF in prolog  at [row,col
    {unknown-source}]: [1,0]  at
    com.ctc.wstx.sr.StreamScanner.throwUnexpectedEOF(StreamScanner.java:682)
      at
    com.ctc.wstx.sr.BasicStreamReader.handleEOF(BasicStreamReader.java:2090)
      at
    com.ctc.wstx.sr.BasicStreamReader.nextFromProlog(BasicStreamReader.java:1996)
      at
    com.ctc.wstx.sr.BasicStreamReader.next(BasicStreamReader.java:1100)
      at
    com.ctc.wstx.sr.BasicStreamReader.nextTag(BasicStreamReader.java:1123)
      at
    org.apache.cxf.binding.soap.interceptor.ReadHeadersInterceptor.handleMessage(ReadHeadersInterceptor.java:122)
      ... 40 more</p>
  </blockquote>
  
  <p>Thanks, Daniela</p>