4 Replies Latest reply on Aug 24, 2016 11:42 AM by mgorgon

    JBossWS CXF DataHandler Inputstream empty

    slbanal

      Hi,

       

      Anyone had any issues integrating JBossWS CXF  + MTOM + DataHandler with their web service? I enabled MTOM in my web service implementation and my CXF client to receive/send files using DataHandlers in generated code. Based on my logs, the DataHandlers received by my web service contains the bytes sent by the client but when I use the InputStream of the DataHandler to save the file on disk, the file size is zero for some of the files. Strange thing is I sent two files and one text file (small < 1kb) I was able to save from my service implementation containing the right content. The other files on the other hand like documents/images have zero size.

       

      Using JBoss CXF 4.1.1.Final , JBoss AS 7.1.1.Final

       

      Thanks,

      Stephen

        • 1. Re: JBossWS CXF DataHandler Inputstream empty
          ckulenk

          Hi,

          we have a similar problem at the moment (currently investigating). Maybe it is related to this bug: https://issues.apache.org/jira/browse/CXF-4551

           

          Kind regards,

          Christian

          • 2. Re: JBossWS CXF DataHandler Inputstream empty
            mgorgon

            Hi,


            This bug still exists - verified at CXF 3.1.7.

            • 3. Re: JBossWS CXF DataHandler Inputstream empty
              jim.ma

              There are some tests are added for this issue [CXF-4551] MTOM + SchemaValidation results in empty input stream from data handler - ASF JIRA in cxf and one of them is

              systests/uncategorized/src/test/java/org/apache/cxf/systest/mtom/ClientMtomXopTest.java. I saw this is in cxf 3.1.7 too: https://github.com/apache/cxf/blob/cxf-3.1.7/systests/uncategorized/src/test/java/org/apache/cxf/systest/mtom/ClientMtomXopTest.java#L122

              Can you please explain it more about the bug you met ?  Is it the same issue with the CXF-4551?

              • 4. Re: JBossWS CXF DataHandler Inputstream empty
                mgorgon

                It seems like these tests checks XOP with schema validation at client side, but not at the endpoint side, nor content of stream at endpoint side is tested.

                Here are few details:

                 

                - webservice is exposed via spring in tomcat,

                - MTOM is enabled at endpoint by @MTOM(enabled = true)

                - schema validation enabled at endpoint by @SchemaValidation(type = SchemaValidationType.BOTH)

                - service build with wsdl first

                - jaxws21 frontent (no Holders)

                - logging interceptors and WS-Security doesn't make difrerence.

                 

                 

                Just open cxf/EchoService.java at cxf-3.1.7 · apache/cxf · GitHub and add @SchemaValidation(type = SchemaValidationType.BOTH) annotation and run cxf/MtomServerTest.java at cxf-3.1.7 · apache/cxf · GitHub

                 

                testMtomRequest will fail with:

                 

                java.lang.AssertionError: expected:<27364> but was:<0>

                    at org.junit.Assert.fail(Assert.java:88)

                    at org.junit.Assert.failNotEquals(Assert.java:834)

                    at org.junit.Assert.assertEquals(Assert.java:645)

                    at org.junit.Assert.assertEquals(Assert.java:631)

                    at org.apache.cxf.systest.mtom.MtomServerTest.testMtomRequest(MtomServerTest.java:127)

                    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

                    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)

                    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

                    at java.lang.reflect.Method.invoke(Method.java:497)

                    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)

                    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)

                    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)

                    at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)

                    at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)

                    at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)

                    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)

                    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)

                    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)

                    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)

                    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)

                    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)

                    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)

                    at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)

                    at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)

                    at org.junit.runners.ParentRunner.run(ParentRunner.java:363)

                    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86)

                    at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)

                    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)

                    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:678)

                    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)

                    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)