title: javax.xml.ws.soap.SOAPFaultException: Error reading XMLStreamReader: Unexpected EOF in prolog at [row,col {unknown-source}]: [1,0]
body: <p>I am trying to invoke soap webservice over https protocal.</p>
  
  <p>I have wsdl and generated classes by using Apache CXF, version : 3.0.5</p>
  
  <p>when i post the request in soapui, i am getting successfull response from server</p>
  
  <p>but when the same is invoked from Java client getting error : <code>javax.xml.ws.soap.SOAPFaultException: Error reading XMLStreamReader: Unexpected EOF in prolog</code></p>
  
  <p>Below is java code</p>
  
  <pre><code>package com.cts.pepsi.util;
  
  import java.text.SimpleDateFormat;
  import java.util.ArrayList;
  import java.util.Date;
  import java.util.List;
  import java.util.Map;
  
  import javax.xml.ws.BindingProvider;
  
  import org.apache.cxf.jaxws.JaxWsProxyFactoryBean;
  import org.slf4j.Logger;
  import org.slf4j.LoggerFactory;
  
  import com.oracle.xmlns.apps.financials.commonmodules.shared.model.erpintegrationservice.DocumentDetails;
  import com.oracle.xmlns.apps.financials.commonmodules.shared.model.erpintegrationservice.ErpIntegrationService;
  import com.oracle.xmlns.apps.financials.commonmodules.shared.model.erpintegrationservice.ErpIntegrationService_Service;
  import com.oracle.xmlns.apps.financials.commonmodules.shared.model.erpintegrationservice.EssJob;
  import com.oracle.xmlns.apps.financials.commonmodules.shared.model.erpintegrationservice.ObjectFactory;
  
  
  
  public class SoapClient {
      private static final Logger           log      = LoggerFactory.getLogger(SoapClient.class);
  
      private String username = "username";
      private String password = "password";
  
      static ErpIntegrationService erpIntegrationService;
      static long value = 0;
      public static void main(String[] args) {
          log.info("START : Invoking  service");
          System.out.println("done");
  
          try {
  
              String documentAccount = null;
              String documentTitle = null;
              String fileName = null;
              String interfaceDetails = null;
              String jobName = null;
              String jobParams = null;
              EssJob essJob = new EssJob();
              List&lt;EssJob&gt; jobList = new ArrayList&lt;EssJob&gt;();
              ObjectFactory erpobjfac = new ObjectFactory();
  
                  documentAccount = "abc$/xyz$/take$";
                  documentTitle = "ekat throw bill";
                  fileName = "abcd.zip";
  
                  interfaceDetails = "2";
  
                  jobName = "/pqr/stu/ddd/fdg/qwe/tyu/poi,lkj";
                  jobParams = "090900909090909090909,andis,2016/05/17,,,,,,,,,,,,,,,,,,,,Y,null";
  
                  essJob.setJobName(erpobjfac.createEssJobJobName(jobName));
                  essJob.setParameterList(erpobjfac.createEssJobParameterList(jobParams));
                  jobList.add(essJob);
  
  
              System.out.println("iiiii  ");
              StringBuffer encodedContent = new StringBuffer();
              encodedContent.append("encoded content");//here Base64 encoded data is appended
  
              //DocumentDetails
              DocumentDetails docDtls = new DocumentDetails();
              docDtls.setDocumentAccount(erpobjfac.createDocumentDetailsDocumentAccount(documentAccount));
              docDtls.setContentType(erpobjfac.createDocumentDetailsContentType("zip"));
              docDtls.setDocumentTitle(erpobjfac.createDocumentDetailsDocumentTitle(documentTitle));
              docDtls.setFileName(fileName);
              docDtls.setDocumentSecurityGroup(erpobjfac.createDocumentDetailsDocumentSecurityGroup("FAFtakeExcellent"));
              docDtls.setContent(encodedContent.toString().getBytes());
  
  
              //NotificationCode
              String notificationCode = "50";
  
              //CallBackURL
              String callbackURL = "http://somecallbackserver.domain.com/mycallback";
  
  
              new SoapClient().authenticate();
              JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
              factory.setServiceClass(ErpIntegrationService.class);
              //factory.setAddress("https://eeln-test.fin.us2.oraclecloud.com:443/publicFinancialCommonErpIntegration/ErpIntegrationService");
              factory.setAddress("http://xmlns.oracle.com/apps/financials/commonModules/shared/model/erpIntegrationService/loadAndImportData");
              factory.getInInterceptors().add(new org.apache.cxf.interceptor.LoggingInInterceptor());
              factory.getOutInterceptors().add(new org.apache.cxf.interceptor.LoggingOutInterceptor());
              //ErpIntegrationService erpIntServiceSoap = (ErpIntegrationService) factory.create();
              erpIntegrationService = (ErpIntegrationService) factory.create();
  
  
              value = erpIntegrationService.loadAndImportData(docDtls, jobList, interfaceDetails, notificationCode, callbackURL);
              System.out.println("value is not :- "+value);
          }
          catch (Exception e) {
              log.error("An exception occurred, exiting", e);
          }
      }
  
      public &lt;K&gt; void authenticate() {
            log.info("Entering authenticate ");
            try {
             ErpIntegrationService_Service erpIntgService_Service = new ErpIntegrationService_Service();
  
             this.erpIntegrationService = erpIntgService_Service.getErpIntegrationServiceSoapHttpPort();
             Map requestCredentails = ((BindingProvider) this.erpIntegrationService).getRequestContext();
             requestCredentails.put("javax.xml.ws.security.auth.username", this.username);
             requestCredentails.put("javax.xml.ws.security.auth.password", this.password);
             log.info("Exiting authenticate ");
            } catch (Exception exception) {
             log.info("Error in authenticate " + exception.getMessage());
            }
           }
  
  }
  </code></pre>
  
  <h1>below is the log</h1>
  
  <pre><code>javax.xml.ws.soap.SOAPFaultException: Error reading XMLStreamReader: Unexpected EOF in prolog
   at [row,col {unknown-source}]: [1,0]
      at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:160)
      at com.sun.proxy.$Proxy52.loadAndImportData(Unknown Source)
      at com.cts.pepsi.util.SoapClient.main(SoapClient.java:109)
  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:685)
      at com.ctc.wstx.sr.BasicStreamReader.handleEOF(BasicStreamReader.java:2141)
      at com.ctc.wstx.sr.BasicStreamReader.nextFromProlog(BasicStreamReader.java:2047)
      at com.ctc.wstx.sr.BasicStreamReader.next(BasicStreamReader.java:1131)
      at com.ctc.wstx.sr.BasicStreamReader.nextTag(BasicStreamReader.java:1154)
      at org.apache.cxf.binding.soap.interceptor.ReadHeadersInterceptor.handleMessage(ReadHeadersInterceptor.java:165)
      at org.apache.cxf.binding.soap.interceptor.ReadHeadersInterceptor.handleMessage(ReadHeadersInterceptor.java:66)
      at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:307)
      at org.apache.cxf.endpoint.ClientImpl.onMessage(ClientImpl.java:802)
      at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponseInternal(HTTPConduit.java:1645)
      at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponse(HTTPConduit.java:1533)
      at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.close(HTTPConduit.java:1336)
      at org.apache.cxf.io.CacheAndWriteOutputStream.postClose(CacheAndWriteOutputStream.java:56)
      at org.apache.cxf.io.CachedOutputStream.close(CachedOutputStream.java:215)
      at org.apache.cxf.transport.AbstractConduit.close(AbstractConduit.java:56)
      at org.apache.cxf.transport.http.HTTPConduit.close(HTTPConduit.java:652)
      at org.apache.cxf.interceptor.MessageSenderInterceptor$MessageSenderEndingInterceptor.handleMessage(MessageSenderInterceptor.java:62)
      at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:307)
      at org.apache.cxf.endpoint.ClientImpl.doInvoke(ClientImpl.java:516)
      at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:425)
      at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:326)
      at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:279)
      at org.apache.cxf.frontend.ClientProxy.invokeSync(ClientProxy.java:96)
      at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:138)
      ... 2 more
  </code></pre>
  
  <p>i have taken the soap request from the logs and posted from SOAP ui, it worked fine.</p>
  
  <p><strong><em>i have tried to invoke all operations which exists in wsdl from Java client and the same error is repeated</em></strong></p>
  
  <p>below is wsdl policy</p>
  
  <pre><code>&lt;wsp:Policy xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" wsu:Id="ErpIntegrationServiceSoapHttpPort_Input_Policy" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy"&gt;
     &lt;wsp:ExactlyOne&gt;
        &lt;wsp:All&gt;
           &lt;sp:SignedParts xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy"&gt;
              &lt;sp:Body/&gt;
              &lt;sp:Header Namespace="http://www.w3.org/2005/08/addressing"/&gt;
              &lt;sp:Header Namespace="http://schemas.xmlsoap.org/ws/2004/08/addressing"/&gt;
              &lt;sp:Header Name="fmw-context" Namespace="http://xmlns.oracle.com/fmw/context/1.0"/&gt;
           &lt;/sp:SignedParts&gt;
           &lt;sp:EncryptedParts xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy"&gt;
              &lt;sp:Body/&gt;
              &lt;sp:Header Name="fmw-context" Namespace="http://xmlns.oracle.com/fmw/context/1.0"/&gt;
           &lt;/sp:EncryptedParts&gt;
        &lt;/wsp:All&gt;
        &lt;wsp:All&gt;
           &lt;sp:SignedParts xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy"&gt;
              &lt;sp:Body/&gt;
              &lt;sp:Header Namespace="http://www.w3.org/2005/08/addressing"/&gt;
              &lt;sp:Header Namespace="http://schemas.xmlsoap.org/ws/2004/08/addressing"/&gt;
              &lt;sp:Header Name="fmw-context" Namespace="http://xmlns.oracle.com/fmw/context/1.0"/&gt;
           &lt;/sp:SignedParts&gt;
           &lt;sp:EncryptedParts xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy"&gt;
              &lt;sp:Body/&gt;
              &lt;sp:Header Name="fmw-context" Namespace="http://xmlns.oracle.com/fmw/context/1.0"/&gt;
           &lt;/sp:EncryptedParts&gt;
        &lt;/wsp:All&gt;
        &lt;wsp:All&gt;
           &lt;sp:SignedParts xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy"&gt;
              &lt;sp:Body/&gt;
              &lt;sp:Header Namespace="http://www.w3.org/2005/08/addressing"/&gt;
              &lt;sp:Header Namespace="http://schemas.xmlsoap.org/ws/2004/08/addressing"/&gt;
              &lt;sp:Header Name="fmw-context" Namespace="http://xmlns.oracle.com/fmw/context/1.0"/&gt;
           &lt;/sp:SignedParts&gt;
           &lt;sp:EncryptedParts xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy"&gt;
              &lt;sp:Body/&gt;
              &lt;sp:Header Name="fmw-context" Namespace="http://xmlns.oracle.com/fmw/context/1.0"/&gt;
           &lt;/sp:EncryptedParts&gt;
        &lt;/wsp:All&gt;
        &lt;wsp:All&gt;
           &lt;sp:SignedParts xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy"&gt;
              &lt;sp:Body/&gt;
              &lt;sp:Header Namespace="http://www.w3.org/2005/08/addressing"/&gt;
              &lt;sp:Header Namespace="http://schemas.xmlsoap.org/ws/2004/08/addressing"/&gt;
              &lt;sp:Header Name="fmw-context" Namespace="http://xmlns.oracle.com/fmw/context/1.0"/&gt;
           &lt;/sp:SignedParts&gt;
           &lt;sp:EncryptedParts xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy"&gt;
              &lt;sp:Body/&gt;
              &lt;sp:Header Name="fmw-context" Namespace="http://xmlns.oracle.com/fmw/context/1.0"/&gt;
           &lt;/sp:EncryptedParts&gt;
        &lt;/wsp:All&gt;
     &lt;/wsp:ExactlyOne&gt;
  &lt;/wsp:Policy&gt;
  </code></pre>
  
  <p>requesting you to please help where i have committed the mistake in java code, thanks</p>