[ 
https://issues.apache.org/jira/browse/CXF-1524?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12590952#action_12590952
 ] 

Daniel Kulp commented on CXF-1524:
----------------------------------


OK.  I have a reproduceable test for this.   It's not a bug in CXF.  It's a bug 
in the Sun SAAJ implementation.  :-(

Basically, if you create a SOAPMessage from an InputStream that is pretty large 
or at least has large attachments,  then call getSOAPBody() on it (to see if 
it's a fault for example), it ends up closing the stream and then when we want 
to iterate/count the attachments, it barfs.

The workaround is to just call msg.countAttachments() right after creating the 
SOAPMessage to suck the attachments in and get  them initialized.   I'll add 
that to the DispatchInDatabindingInterceptor.   The testcase works with that in 
place.




> SOAP with Attachments (BMMimeMultipart):  DispatchInDatabindingInterceptor 's 
> call to soapMessage.countAttachments() throws IOException 
> ----------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: CXF-1524
>                 URL: https://issues.apache.org/jira/browse/CXF-1524
>             Project: CXF
>          Issue Type: Bug
>          Components: Soap Binding
>    Affects Versions: 2.0.4, 2.0.5
>         Environment: CXF used to call a WebService (client-mode): WS called 
> uses SOAP  with Attachments document/literal wrapped style. client uses 
> dispatch method and Service.Mode.MESSAGE. saaj-api 1.3 and saaj-impl 1.3 , 
> jaxb-api 2.1 all endorsed. called from a junit test case.
>            Reporter: Alex F
>            Assignee: Daniel Kulp
>            Priority: Critical
>
> The following call throws a IOException:
> SOAPMessage soapResponseMsg = disp.invoke(soapRequestMsg);
> The response is a SOAP Message with 2 Attachments. One small xml and one 
> rather big pdf (250kb). When the DispatchInDatabindingInterceptor calls 
> oapMessage.countAttachments() the underlying BMMimeMultipart class throws an 
> IOExcpetion. 
> One important thing to mention is that the same code works perfectly when 
> only one xml attachment is returned by the called webservice. Another 
> interesting thing is that in the logging below it states that the message was 
> saved to an tmp file. but when i look at that place there is none. Could that 
> be the reason for the IO  -Handle - exception? 
> Logs:
> 11.04.2008 09:20:10 org.apache.cxf.interceptor.LoggingInInterceptor logging
> INFO: Inbound Message
> ----------------------------
> Encoding: UTF-8
> Headers: {content-type=[multipart/related; type="text/xml"; 
> start="<3EB558C5A498923F1340808112DC20DF>";  
> boundary="----=_Part_361_17089125.1207898405321"], connection=[Keep-Alive], 
> transfer-encoding=[chunked], Date=[Fri, 11 Apr 2008 07:20:05 GMT], 
> Keep-Alive=[timeout=15, max=100], Server=[Apache]}
> Messages: 
> Message (saved to tmp file):
> Filename: C:\DOKUME~1\XXXXXX\LOKALE~1\Temp\cxf-tmp-105260\cos27407tmp
> (message truncated to 102400 bytes)
> Payload: 
> ------=_Part_361_17089125.1207898405321
> Content-Type: text/xml; charset=UTF-8
> Content-Transfer-Encoding: binary
> Content-Id: <3EB558C5A498923F1340808112DC20DF>
> call throws the following Stacktrace:
> 11.04.2008 09:20:36 org.apache.cxf.phase.PhaseInterceptorChain doIntercept
> INFO: Interceptor has thrown exception, unwinding now
> java.lang.RuntimeException: 
> com.sun.xml.messaging.saaj.packaging.mime.MessagingException: IO Error;
>   nested exception is:
>       java.io.IOException: Das Handle ist ungültig
>       at 
> com.sun.xml.messaging.saaj.soap.MessageImpl.countAttachments(MessageImpl.java:734)
>       at 
> org.apache.cxf.jaxws.interceptors.DispatchInDatabindingInterceptor$PostDispatchSOAPHandlerInterceptor.handleMessage(DispatchInDatabindingInterceptor.java:221)
>       at 
> org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:220)
>       at org.apache.cxf.jaxws.DispatchImpl.onMessage(DispatchImpl.java:330)
>       at 
> org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponse(HTTPConduit.java:1976)
>       at 
> org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.close(HTTPConduit.java:1812)
>       at 
> org.apache.cxf.io.CacheAndWriteOutputStream.postClose(CacheAndWriteOutputStream.java:47)
>       at 
> org.apache.cxf.io.CachedOutputStream.close(CachedOutputStream.java:159)
>       at 
> org.apache.cxf.transport.AbstractConduit.close(AbstractConduit.java:66)
>       at org.apache.cxf.transport.http.HTTPConduit.close(HTTPConduit.java:582)
>       at 
> org.apache.cxf.interceptor.MessageSenderInterceptor$MessageSenderEndingInterceptor.handleMessage(MessageSenderInterceptor.java:62)
>       at 
> org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:220)
>       at org.apache.cxf.jaxws.DispatchImpl.invoke(DispatchImpl.java:179)
>       at org.apache.cxf.jaxws.DispatchImpl.invoke(DispatchImpl.java:124)
>       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>       at 
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>       at 
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>       at java.lang.reflect.Method.invoke(Method.java:597)
>       at junit.framework.TestCase.runTest(TestCase.java:164)
>       at junit.framework.TestCase.runBare(TestCase.java:130)
>       at 
> org.springframework.test.ConditionalTestCase.runBare(ConditionalTestCase.java:76)
>       at 
> org.springframework.test.annotation.AbstractAnnotationAwareTransactionalTests.access$001(AbstractAnnotationAwareTransactionalTests.java:70)
>       at 
> org.springframework.test.annotation.AbstractAnnotationAwareTransactionalTests$1.run(AbstractAnnotationAwareTransactionalTests.java:186)
>       at 
> org.springframework.test.annotation.AbstractAnnotationAwareTransactionalTests.runTest(AbstractAnnotationAwareTransactionalTests.java:313)
>       at 
> org.springframework.test.annotation.AbstractAnnotationAwareTransactionalTests.runTestTimed(AbstractAnnotationAwareTransactionalTests.java:281)
>       at 
> org.springframework.test.annotation.AbstractAnnotationAwareTransactionalTests.runBare(AbstractAnnotationAwareTransactionalTests.java:182)
>       at 
> org.springframework.test.jpa.AbstractJpaTests.runBare(AbstractJpaTests.java:174)
>       at 
> org.springframework.test.jpa.AbstractJpaTests.runBare(AbstractJpaTests.java:255)
>       at junit.framework.TestResult$1.protect(TestResult.java:110)
>       at junit.framework.TestResult.runProtected(TestResult.java:128)
>       at junit.framework.TestResult.run(TestResult.java:113)
>       at junit.framework.TestCase.run(TestCase.java:120)
>       at junit.framework.TestSuite.runTest(TestSuite.java:228)
>       at junit.framework.TestSuite.run(TestSuite.java:223)
>       at 
> org.junit.internal.runners.OldTestClassRunner.run(OldTestClassRunner.java:35)
>       at 
> org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:38)
>       at 
> org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
>       at 
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
>       at 
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
>       at 
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
>       at 
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
> Caused by: com.sun.xml.messaging.saaj.packaging.mime.MessagingException: IO 
> Error;
>   nested exception is:
>       java.io.IOException: Das Handle ist ungültig
>       at 
> com.sun.xml.messaging.saaj.packaging.mime.internet.BMMimeMultipart.parse(BMMimeMultipart.java:214)
>       at 
> com.sun.xml.messaging.saaj.packaging.mime.internet.MimeMultipart.getCount(MimeMultipart.java:186)
>       at 
> com.sun.xml.messaging.saaj.soap.MessageImpl.initializeAllAttachments(MessageImpl.java:1257)
>       at 
> com.sun.xml.messaging.saaj.soap.MessageImpl.countAttachments(MessageImpl.java:732)
>       ... 43 more

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to