Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Soap Header (Unexpected EOF in prolog)

I have to add Soap header into web-service responce.

I tried to do in couple of ways, first of them:

public SendFileToAlfaOutParms sendFileToAlfa(SendFileToAlfaInParms inParms)
            throws MsgWSException {
        logger.trace(LogMarkers.IN, "sendFileToAlfa(\ninParms={})", inParms);

        List<Header> headers = (List<Header>) wsContext.getMessageContext().get(Header.HEADER_LIST);
        headers.add(new Header(new QName("http://WSBigFilesWEBService.WEB.ws.bf.sbrf.ru", "SendFileToAlfaAntiVirusStatus"), "TEST"));
        wsContext.getMessageContext().put(Header.HEADER_LIST, headers);

        try {
            InputStream fileContent = fileService.download(inParms.getTransferJobGUID(), inParms.getChunkIdx());
            SendFileToAlfaOutParms outParms = new SendFileToAlfaOutParms();
            outParms.setFileContent(new DataHandler(new InputStreamDataSource(fileContent)));
            logger.trace(LogMarkers.OUT, "sendFileToAlfa\n{}", outParms);
            return outParms;
        } catch (Exception e) {
            logger.error("Exception in sendFileToAlfa", e);
            throw new MsgWSException(e.getMessage(), ExceptionHandlingHelper.convertToExceptionInfo(e));
        }
    }

second is through cxf OutInteceptor:

public void handleMessage(SoapMessage message) throws Fault {
    List<Header> list = message.getHeaders();
    QName q = new QName("http://WSBigFilesWEBService.WEB.ws.bf.sbrf.ru", "SendFileToAlfaAntiVirusStatus");
    SoapHeader header = new SoapHeader(q, "TEST");
    list.add(header);
}

So, bouth methods cause an exception:

2015-07-15 17:59:24,719 WARN :[APP] [60069702-34c1-4d4b-9e31-a7282860c10a||DefaultMessageListenerContainer-2] o.a.cxf.phase.PhaseInterceptorChain - []Interceptor for {http://WSBigFilesWEBService.WEB.ws.bf.sbrf.ru}WSBigFilesWEBService#{http://WSBigFilesWEBService.WEB.ws.bf.sbrf.ru}SendFileToAlfa has thrown exception, unwinding now
org.apache.cxf.binding.soap.SoapFault: Error reading XMLStreamReader: Unexpected EOF in prolog
 at [row,col {unknown-source}]: [1,0]
    at org.apache.cxf.binding.soap.interceptor.ReadHeadersInterceptor.handleMessage(ReadHeadersInterceptor.java:259) ~[cxf-rt-bindings-soap-3.0.1.jar:3.0.1]
    at org.apache.cxf.binding.soap.interceptor.ReadHeadersInterceptor.handleMessage(ReadHeadersInterceptor.java:62) ~[cxf-rt-bindings-soap-3.0.1.jar:3.0.1]
    at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:307) [cxf-core-3.0.1.jar:3.0.1]
    at org.apache.cxf.endpoint.ClientImpl.onMessage(ClientImpl.java:798) [cxf-core-3.0.1.jar:3.0.1]
    at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponseInternal(HTTPConduit.java:1636) [cxf-rt-transports-http-3.0.1.jar:3.0.1]
    at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponse(HTTPConduit.java:1525) [cxf-rt-transports-http-3.0.1.jar:3.0.1]
    at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.close(HTTPConduit.java:1330) [cxf-rt-transports-http-3.0.1.jar:3.0.1]
    at org.apache.cxf.transport.AbstractConduit.close(AbstractConduit.java:56) [cxf-core-3.0.1.jar:3.0.1]
    at org.apache.cxf.transport.http.HTTPConduit.close(HTTPConduit.java:638) [cxf-rt-transports-http-3.0.1.jar:3.0.1]
    at org.apache.cxf.interceptor.MessageSenderInterceptor$MessageSenderEndingInterceptor.handleMessage(MessageSenderInterceptor.java:62) [cxf-core-3.0.1.jar:3.0.1]
    at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:307) [cxf-core-3.0.1.jar:3.0.1]
    at org.apache.cxf.endpoint.ClientImpl.doInvoke(ClientImpl.java:514) [cxf-core-3.0.1.jar:3.0.1]
    at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:423) [cxf-core-3.0.1.jar:3.0.1]
    at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:326) [cxf-core-3.0.1.jar:3.0.1]
    at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:279) [cxf-core-3.0.1.jar:3.0.1]
    at org.apache.cxf.frontend.ClientProxy.invokeSync(ClientProxy.java:96) [cxf-rt-frontend-simple-3.0.1.jar:3.0.1]
    at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:137) [cxf-rt-frontend-jaxws-3.0.1.jar:3.0.1]
    at com.sun.proxy.$Proxy112.sendFileToAlfa(Unknown Source) [na:na]
    at ru.sbrf.bf.alfa.io.ws.client.FileServiceStub.download(FileServiceStub.java:82) [classes/:na]
    at ru.sbrf.bf.alfa.services.impl.TransferJobServiceImpl.fileTransferFromDMZToAlfa(TransferJobServiceImpl.java:251) [classes/:na]
    at ru.sbrf.bf.alfa.services.impl.TransferJobServiceImpl$$FastClassBySpringCGLIB$$367c8f5f.invoke(<generated>) [spring-core-4.1.0.RELEASE.jar:na]
    at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204) [spring-core-4.1.0.RELEASE.jar:4.1.0.RELEASE]
    at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:717) [spring-aop-4.1.0.RELEASE.jar:4.1.0.RELEASE]
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157) [spring-aop-4.1.0.RELEASE.jar:4.1.0.RELEASE]
    at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:98) [spring-tx-4.1.0.RELEASE.jar:4.1.0.RELEASE]
    at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:266) [spring-tx-4.1.0.RELEASE.jar:4.1.0.RELEASE]
    at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:95) [spring-tx-4.1.0.RELEASE.jar:4.1.0.RELEASE]
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) [spring-aop-4.1.0.RELEASE.jar:4.1.0.RELEASE]
    at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:653) [spring-aop-4.1.0.RELEASE.jar:4.1.0.RELEASE]
    at ru.sbrf.bf.alfa.services.impl.TransferJobServiceImpl$$EnhancerBySpringCGLIB$$ea1aa57c.fileTransferFromDMZToAlfa(<generated>) [spring-core-4.1.0.RELEASE.jar:na]
    at ru.sbrf.bf.alfa.events.jms.listeners.TransferDMZToAlphaListener.handleMessage(TransferDMZToAlphaListener.java:50) [classes/:na]
    at ru.sbrf.bf.alfa.events.jms.listeners.TransferDMZToAlphaListener.handleMessage(TransferDMZToAlphaListener.java:28) [classes/:na]
    at ru.sbrf.bf.alfa.io.jms.handler.impl.JmsMessageHandler.handleMessage(JmsMessageHandler.java:27) [big-files-app-jms-0.2.3.jar:na]
    at ru.sbrf.bf.alfa.io.jms.listener.impl.JmsCommonMessageListener.onMessage(JmsCommonMessageListener.java:42) [big-files-app-jms-0.2.3.jar:na]
    at org.springframework.jms.listener.AbstractMessageListenerContainer.doInvokeListener(AbstractMessageListenerContainer.java:685) [spring-jms-4.1.0.RELEASE.jar:4.1.0.RELEASE]
    at org.springframework.jms.listener.AbstractMessageListenerContainer.invokeListener(AbstractMessageListenerContainer.java:623) [spring-jms-4.1.0.RELEASE.jar:4.1.0.RELEASE]
    at org.springframework.jms.listener.AbstractMessageListenerContainer.doExecuteListener(AbstractMessageListenerContainer.java:591) [spring-jms-4.1.0.RELEASE.jar:4.1.0.RELEASE]
    at org.springframework.jms.listener.AbstractPollingMessageListenerContainer.doReceiveAndExecute(AbstractPollingMessageListenerContainer.java:308) [spring-jms-4.1.0.RELEASE.jar:4.1.0.RELEASE]
    at org.springframework.jms.listener.AbstractPollingMessageListenerContainer.receiveAndExecute(AbstractPollingMessageListenerContainer.java:246) [spring-jms-4.1.0.RELEASE.jar:4.1.0.RELEASE]
    at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.invokeListener(DefaultMessageListenerContainer.java:1137) [spring-jms-4.1.0.RELEASE.jar:4.1.0.RELEASE]
    at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.executeOngoingLoop(DefaultMessageListenerContainer.java:1129) [spring-jms-4.1.0.RELEASE.jar:4.1.0.RELEASE]
    at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.run(DefaultMessageListenerContainer.java:1031) [spring-jms-4.1.0.RELEASE.jar:4.1.0.RELEASE]
    at java.lang.Thread.run(Thread.java:745) [na:1.7.0_71]
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) ~[woodstox-core-asl-4.4.0.jar:4.4.0]
    at com.ctc.wstx.sr.BasicStreamReader.handleEOF(BasicStreamReader.java:2141) ~[woodstox-core-asl-4.4.0.jar:4.4.0]
    at com.ctc.wstx.sr.BasicStreamReader.nextFromProlog(BasicStreamReader.java:2047) ~[woodstox-core-asl-4.4.0.jar:4.4.0]
    at com.ctc.wstx.sr.BasicStreamReader.next(BasicStreamReader.java:1131) ~[woodstox-core-asl-4.4.0.jar:4.4.0]
    at com.ctc.wstx.sr.BasicStreamReader.nextTag(BasicStreamReader.java:1154) ~[woodstox-core-asl-4.4.0.jar:4.4.0]
    at org.apache.cxf.binding.soap.interceptor.ReadHeadersInterceptor.handleMessage(ReadHeadersInterceptor.java:158) ~[cxf-rt-bindings-soap-3.0.1.jar:3.0.1]
    ... 42 common frames omitted

Why added header cause some error in prolog?

like image 428
heyDude Avatar asked Jul 15 '15 14:07

heyDude


People also ask

Why am I getting an EOF error when sending a SOAP response?

Just adding onto this answer rather than adding an answer: The EOF error can also happen if the SOAP response body does not match the Content-Length response header if it's present. The underlying HTTP client may or may not verify the Content-Length against the response body.

Why am I getting a blank SOAP response error?

This error is given when a blank (empty) SOAP response is given to the Web Service consumer. Integration Server is giving the message trying to parse and empty reply. Contact the Web Service provider to explain why a blank response from given to the request. [/b]

Is there any additional content in front of XML prolog?

Note: There is no additional content in front of XML prolog “<?xml version="1.0"?>”. Any suggestions. Any help here or suggestion on this issue. This is soap fault we are getting from the server that hosts the webservice.


1 Answers

I found the solution:

http://cxf.apache.org/faq.html#FAQ-HowcanIaddsoapheaderstotherequest/response?

The cause was a missing DataBinding.

List<Header> headers = new ArrayList<Header>();
Header dummyHeader = new Header(new QName("antiVirusStatus"), "clean", new JAXBDataBinding(String.class));
headers.add(dummyHeader);
wsContext.getMessageContext().put(Header.HEADER_LIST, headers);
like image 196
heyDude Avatar answered Oct 27 '22 00:10

heyDude