2 Replies Latest reply on Aug 25, 2017 2:14 AM by chiochuan1

    camel-cxf: unwrapped style web service returning empty body when schema-validation-enabled=true

    chiochuan

      Dear team,

       

      could you help me for below issue?

      i trying to read the body response for the web service but encounter below exception.

       

      Based on the test, these only happen for unwrapped style web services.

      i have tried with wrapped style and there is no issue for that.

       

      FYI, this is only happen for jboss release, e.g 2.17.0.redhat-630XXX, but when i try wth camel 2.17.0, there are no issue.

      Not sure if this is a bug or mistake on my end.

       

      Attach is the test case.

       

      Stacktrace

      ---------------------------------------------------------------------------------------------------------------------------------------

      org.apache.camel.TypeConversionException: Error during type conversion from type: java.lang.String to the required type: java.lang.String with value [Body is instance of org.apache.camel.StreamCache] due java.lang.IllegalStateException: StAXSource(XMLStreamReader) with XMLStreamReadernot in XMLStreamConstants.START_DOCUMENT or XMLStreamConstants.START_ELEMENT state

              at org.apache.camel.impl.converter.BaseTypeConverterRegistry.createTypeConversionException(BaseTypeConverterRegistry.java:629)

              at org.apache.camel.impl.converter.BaseTypeConverterRegistry.convertTo(BaseTypeConverterRegistry.java:150)

              at org.apache.camel.support.ExpressionAdapter.evaluate(ExpressionAdapter.java:41)

              at org.apache.camel.processor.LogProcessor.process(LogProcessor.java:53)

              at org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:468)

              at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:196)

              at org.apache.camel.processor.ChoiceProcessor.process(ChoiceProcessor.java:117)

              at org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:468)

              at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:196)

              at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:196)

              at org.apache.camel.component.direct.DirectProducer.process(DirectProducer.java:62)

              .......

        • 1. Re: camel-cxf: unwrapped style web service returning empty body when schema-validation-enabled=true
          vrlgohel

          You are using PAYLOAD and by default CXF does not do schema validation. If the schema validation is enabled, then CXF uses validation in databinding on JAXB like when marshal/unmarshal. Hence, with PAYLOAD the schema validation does not work.

          • 2. Re: camel-cxf: unwrapped style web service returning empty body when schema-validation-enabled=true
            chiochuan1

            I not sure if that really correct, but when i try to response with wrong response, CXF did throw error.

             

             

            org.apache.cxf.interceptor.Fault: "schema-error" does not satisfy the "int" type

            at org.apache.cxf.staxutils.validation.Stax2ValidationUtils$2.reportProblem(Stax2ValidationUtils.java:116)

            at com.ctc.wstx.sw.BaseStreamWriter.reportProblem(BaseStreamWriter.java:1181)

            at com.ctc.wstx.msv.GenericMsvValidator.reportError(GenericMsvValidator.java:538)

            at com.ctc.wstx.msv.GenericMsvValidator.reportError(GenericMsvValidator.java:530)

            at com.ctc.wstx.msv.GenericMsvValidator.reportError(GenericMsvValidator.java:524)

            at com.ctc.wstx.msv.GenericMsvValidator.doValidateText(GenericMsvValidator.java:511)

            at com.ctc.wstx.msv.GenericMsvValidator.validateElementEnd(GenericMsvValidator.java:371)

            at com.ctc.wstx.sw.BaseNsStreamWriter.doWriteEndTag(BaseNsStreamWriter.java:726)

            at com.ctc.wstx.sw.BaseNsStreamWriter.writeEndElement(BaseNsStreamWriter.java:280)

            at org.apache.cxf.staxutils.StaxUtils.copy(StaxUtils.java:742)

            at org.apache.cxf.staxutils.StaxUtils.copy(StaxUtils.java:702)

            at org.apache.cxf.databinding.source.XMLStreamDataReader.validate(XMLStreamDataReader.java:244)

            at org.apache.cxf.databinding.source.XMLStreamDataReader.read(XMLStreamDataReader.java:115)

            at org.apache.cxf.databinding.source.XMLStreamDataReader.read(XMLStreamDataReader.java:83)

            at org.apache.cxf.databinding.source.XMLStreamDataReader.read(XMLStreamDataReader.java:67)

            at org.apache.cxf.wsdl.interceptors.DocLiteralInInterceptor.handleMessage(DocLiteralInInterceptor.java:109)

            at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:308)

            at org.apache.cxf.endpoint.ClientImpl.onMessage(ClientImpl.java:780)

            at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponseInternal(HTTPConduit.java:1670)

            at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream$1.run(HTTPConduit.java:1168)

            at org.apache.cxf.workqueue.AutomaticWorkQueueImpl$3.run(AutomaticWorkQueueImpl.java:428)

            at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)

            at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)

            at org.apache.cxf.workqueue.AutomaticWorkQueueImpl$AWQThreadFactory$1.run(AutomaticWorkQueueImpl.java:353)

            at java.lang.Thread.run(Thread.java:748)