Uploaded image for project: 'CXF'
  1. CXF
  2. CXF-2455

Unable to disable schema validation in 2.2.4-SNAPSHOT

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.2.4
    • Fix Version/s: 2.2.4
    • Component/s: None
    • Labels:
      None

      Description

      Hello,

      It seems I am unable to disable schema validation CXF 2.2.4-SNAPSHOT as it is enabled by default?

      <jaxws:endpoint
      id="testService"
      implementor="testServiceImpl"
      wsdlLocation="wsdl/v29/testService.wsdl"
      address="/v29/testService">
      <jaxws:properties>
      <entry key="schema-validation-enabled" value="false" />
      </jaxws:properties>
      <jaxws:inInterceptors>
      <ref bean="testInterceptor" />
      </jaxws:inInterceptors>
      </jaxws:endpoint>

      This works in 2.2.3 as I am able to disable schema validation to perform custom checks myself. However, in the latest 2.2.4-SNAPSHOT, I am not longer able to disable the schema validation. Is there another way to do this without touching the Endpoint Service Interface/Class? I am using a WSDL first approach to develop my services.

      Best Regards,
      Arik.

        Activity

        Hide
        agorelik Arik Gorelik added a comment -

        Thank you very much. I got the latest snapshot and was able to turn off the
        default jaxb validation event handler for now.

        // Fix in CXF 2.2.4 to disable jaxb default validation
        message.put("set-jaxb-validation-event-handler", false);
        message.put("jaxb-validation-event-handler", null);

        I'll see if I can find a way to use the default validation and also use my
        validation together. Ideally, that would be great for me, but that's a
        challenge as the default jaxb validation does not allow me to get past
        DocLiteralInInterceptor and only past that interceptor I can return custom
        exception types (from the schema) which are filled in with the
        bindings/values that I want.

        Best Regards,
        Arik.

        Show
        agorelik Arik Gorelik added a comment - Thank you very much. I got the latest snapshot and was able to turn off the default jaxb validation event handler for now. // Fix in CXF 2.2.4 to disable jaxb default validation message.put("set-jaxb-validation-event-handler", false); message.put("jaxb-validation-event-handler", null); I'll see if I can find a way to use the default validation and also use my validation together. Ideally, that would be great for me, but that's a challenge as the default jaxb validation does not allow me to get past DocLiteralInInterceptor and only past that interceptor I can return custom exception types (from the schema) which are filled in with the bindings/values that I want. Best Regards, Arik.
        Hide
        dkulp Daniel Kulp added a comment -

        Added two properties:

        "set-jaxb-validation-event-handler" -> Boolean
        which can be set to false to completely NOT set any sort of event handler.

        "jaxb-validation-event-handler" -> ValidationEventHandler object
        if you want to set your own custom handler.

        Note: both properties are contextual off the message. Thus, an interceptor prior to the DocLitIn... could set the properties. It doesn't need to be a configuration thing or similar.

        Show
        dkulp Daniel Kulp added a comment - Added two properties: "set-jaxb-validation-event-handler" -> Boolean which can be set to false to completely NOT set any sort of event handler. "jaxb-validation-event-handler" -> ValidationEventHandler object if you want to set your own custom handler. Note: both properties are contextual off the message. Thus, an interceptor prior to the DocLitIn... could set the properties. It doesn't need to be a configuration thing or similar.
        Hide
        agorelik Arik Gorelik added a comment -

        Looks like after experimenting more with this, in 2.2.4-SNAPSHOT, the schema validation setting is ignored?

        I just sending a simple integer type in an <id> element like this:

        <id>12345a</id>

        but getting a validation error which I would like to turn off and able to do so in 2.2.3. Moreover, in 2.2.3 in the UNMARSHAL phase, the value is being set to "null" in case of invalid values for the elements based on the schema types.

        Here is the stack trace:

        DefaultValidationEventHandler: [ERROR]: For input string: "12345a"
        Location: line 11
        Sep 30, 2009 8:47:21 PM org.apache.cxf.phase.PhaseInterceptorChain doIntercept
        WARNING: Interceptor has thrown exception, unwinding now
        org.apache.cxf.interceptor.Fault: Unmarshalling Error: For input string: "12345a"
        at org.apache.cxf.jaxb.JAXBEncoderDecoder.unmarshall(JAXBEncoderDecoder.java:661)
        at org.apache.cxf.jaxb.JAXBEncoderDecoder.unmarshall(JAXBEncoderDecoder.java:533)
        at org.apache.cxf.jaxb.io.DataReaderImpl.read(DataReaderImpl.java:119)
        at org.apache.cxf.interceptor.DocLiteralInInterceptor.handleMessage(DocLiteralInInterceptor.java:99)
        at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:236)
        at org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:104)

        Show
        agorelik Arik Gorelik added a comment - Looks like after experimenting more with this, in 2.2.4-SNAPSHOT, the schema validation setting is ignored? I just sending a simple integer type in an <id> element like this: <id>12345a</id> but getting a validation error which I would like to turn off and able to do so in 2.2.3. Moreover, in 2.2.3 in the UNMARSHAL phase, the value is being set to "null" in case of invalid values for the elements based on the schema types. Here is the stack trace: DefaultValidationEventHandler: [ERROR] : For input string: "12345a" Location: line 11 Sep 30, 2009 8:47:21 PM org.apache.cxf.phase.PhaseInterceptorChain doIntercept WARNING: Interceptor has thrown exception, unwinding now org.apache.cxf.interceptor.Fault: Unmarshalling Error: For input string: "12345a" at org.apache.cxf.jaxb.JAXBEncoderDecoder.unmarshall(JAXBEncoderDecoder.java:661) at org.apache.cxf.jaxb.JAXBEncoderDecoder.unmarshall(JAXBEncoderDecoder.java:533) at org.apache.cxf.jaxb.io.DataReaderImpl.read(DataReaderImpl.java:119) at org.apache.cxf.interceptor.DocLiteralInInterceptor.handleMessage(DocLiteralInInterceptor.java:99) at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:236) at org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:104)
        Hide
        agorelik Arik Gorelik added a comment -

        Sorry for the spam, but more info on this...

        I am trying to avoid having my message be processed by the DocLiteralInInterceptor so I wrote my custom intercetor to handle the Fault which I want to throw; however, my custom interceptor does not fire after URIMappingIntercetor and before DocLiteralInInterceptor after I add it to the chain. I've been debugging the code, but not sure why it does not fire.

        This is how I am adding it:

        public TestFaultThrowingInterceptor()

        { super(Phase.UNMARSHAL); addBefore(DocLiteralInInterceptor.class.getName()); }

        public void handleMessage(SoapMessage message) throws Fault {
        // Obtain the fault from the previous phases
        Fault fault = (Fault) message.getContent(Exception.class);
        if (fault != null)

        { throw fault; }

        }

        <jaxws:endpoint
        id="testService"
        implementor="testServiceImpl"
        wsdlLocation="wsdl/v29/testService.wsdl"
        address="/v29/testService">
        <jaxws:properties>
        <entry key="schema-validation-enabled" value="false" />
        </jaxws:properties>
        <jaxws:inInterceptors>
        <ref bean="testInterceptor" />
        <ref bean="testFaultThrowingInterceptor" />
        </jaxws:inInterceptors>
        </jaxws:endpoint>

        Show
        agorelik Arik Gorelik added a comment - Sorry for the spam, but more info on this... I am trying to avoid having my message be processed by the DocLiteralInInterceptor so I wrote my custom intercetor to handle the Fault which I want to throw; however, my custom interceptor does not fire after URIMappingIntercetor and before DocLiteralInInterceptor after I add it to the chain. I've been debugging the code, but not sure why it does not fire. This is how I am adding it: public TestFaultThrowingInterceptor() { super(Phase.UNMARSHAL); addBefore(DocLiteralInInterceptor.class.getName()); } public void handleMessage(SoapMessage message) throws Fault { // Obtain the fault from the previous phases Fault fault = (Fault) message.getContent(Exception.class); if (fault != null) { throw fault; } } <jaxws:endpoint id="testService" implementor="testServiceImpl" wsdlLocation="wsdl/v29/testService.wsdl" address="/v29/testService"> <jaxws:properties> <entry key="schema-validation-enabled" value="false" /> </jaxws:properties> <jaxws:inInterceptors> <ref bean="testInterceptor" /> <ref bean="testFaultThrowingInterceptor" /> </jaxws:inInterceptors> </jaxws:endpoint>
        Hide
        agorelik Arik Gorelik added a comment -

        Now I am thinking that it could be something inside the DocLiteralInInterceptor that causes my custom schema validation to fail.

        Basically prior to the DocLiteralInInterceptor interceptor, I inspect certain SOAP message elements and do message.setContent(Exception.class, Fault); in case I find a problem.

        In CXF 2.2.3, I used to be able to throw this fault from UNMARSHAL phase AFTER DocLiteralInInterceptor, but now, I cannot as I am getting a generic error for schema validation problems.

        Show
        agorelik Arik Gorelik added a comment - Now I am thinking that it could be something inside the DocLiteralInInterceptor that causes my custom schema validation to fail. Basically prior to the DocLiteralInInterceptor interceptor, I inspect certain SOAP message elements and do message.setContent(Exception.class, Fault); in case I find a problem. In CXF 2.2.3, I used to be able to throw this fault from UNMARSHAL phase AFTER DocLiteralInInterceptor, but now, I cannot as I am getting a generic error for schema validation problems.

          People

          • Assignee:
            dkulp Daniel Kulp
            Reporter:
            agorelik Arik Gorelik
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development