Mule
  1. Mule
  2. MULE-4235

Enable validation in a CXF endpoint

    Details

    • Type: Patch submission Patch submission
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.1.3
    • Fix Version/s: 3.1.0
    • Component/s: Modules: CXF
    • Labels:
    • Environment:

      Standalone

    • Includes test case?:
      no
    • User impact:
      Medium
    • Similar Issues:
      MULE-6301Soap envelope is invalid after cxf proxy if validation is enabled
      MULE-5689Mule 3 complains about schema validation on CXF inbound endpoints
      MULE-6045Improve usability to enable WS-Security
      MULE-5683cxf:jaxws-service mtomEnabled doesn't work
      MULE-5240Some XML tags such as <cxf:jaxws-client> shows red in IDEA within an outbound endpoint even though it is valid
      MULE-5203Timeout for CXF / HTTP Client
      MULE-3249CXF Endpoints cannot be configured with generic endpoint elements
      MULE-4290Configuring logging interceptor on a cxf endpoint causes the cxf response to throw an error
      MULE-5691Mule cxf endpoint is not able to call SOAP 1.2 webservice
      MULE-4519Async proxy cxf Inbound endpoint throws NullPointerException

      Description

      CXF allows incoming messages to be automatically validated using the wsdl/xsd. Mule CXF Transport should allow to set this cxf feature using out of the box tags. The code for the cxf feature to allow validation is attached. Currently you can use the attached code and the following config on <inbound- endpoint:>

      <cxf:inbound-endpoint address="http://localhost:8082/services/Foo"
      serviceClass="org.mule.Foo"
      >
      <cxf:features>
      <spring:bean id="SchemaValidationFeature" class="org.mule.transport.cxf.support.SchemaValidationFeature"/>
      </cxf:features>

        Activity

        Hide
        Ken Yagen added a comment -

        stretch task for iteration 22

        Show
        Ken Yagen added a comment - stretch task for iteration 22
        Hide
        Daniel Feist added a comment - - edited

        This is very quick/easy to add, will take some time to implement a test case though. Ideally we would add a functional test case that using this feature/interceptor tests both valid and invalid messages,

        Show
        Daniel Feist added a comment - - edited This is very quick/easy to add, will take some time to implement a test case though. Ideally we would add a functional test case that using this feature/interceptor tests both valid and invalid messages,
        Hide
        asdf sdf added a comment -

        You CANNOT get you want according to the Description. I wasted three days. I don't know wthether the solution is provided by MULE. I seriously disagree the irresponsible attitude.

        If you write like below in a endPoint in configuration:
        <cxf:features>
        <spring:bean id="SchemaValidationFeature" class="org.mule.transport.cxf.support.SchemaValidationFeature"/>
        </cxf:features>

        You MUST override the initialize(Server server, Bus bus) method. the initialize(Bus bus) method is never invoked.
        like this:

        /** Be invoked, if the feature is defined in a endpoint. */
        @Override
        public void initialize(Server server, Bus bus)

        { Service service = server.getEndpoint().getService(); addInterceptors(service); }

        /** Just for all the service */
        @Override
        public void initialize(Bus bus)

        { addInterceptors(bus); }

        private void addInterceptors(InterceptorProvider provider)

        { AbstractPhaseInterceptor<Message> in = new EnabledSchemaValidationInterceptor(); provider.getInInterceptors().add(in); //provider.getInFaultInterceptors().add(in); AbstractPhaseInterceptor<Message> out = new DisabledSchemaValidationInterceptor(); provider.getOutInterceptors().add(out); //provider.getOutFaultInterceptors().add(out); }

        Relevant Classes:

        class EnabledSchemaValidationInterceptor extends AbstractPhaseInterceptor<Message> {
        public EnabledSchemaValidationInterceptor()

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


        public void handleMessage(Message message) throws Fault

        { message.put("schema-validation-enabled",true); }


        }

        /** Do not validate a reponse. */
        class DisabledSchemaValidationInterceptor extends AbstractPhaseInterceptor<Message> {

        public DisabledSchemaValidationInterceptor()

        { super(Phase.MARSHAL); addBefore(BareOutInterceptor.class.getName()); }

        public void handleMessage(Message message) throws Fault

        { message.put("schema-validation-enabled",false); }


        }

        Show
        asdf sdf added a comment - You CANNOT get you want according to the Description. I wasted three days. I don't know wthether the solution is provided by MULE. I seriously disagree the irresponsible attitude. If you write like below in a endPoint in configuration: <cxf:features> <spring:bean id="SchemaValidationFeature" class="org.mule.transport.cxf.support.SchemaValidationFeature"/> </cxf:features> You MUST override the initialize(Server server, Bus bus) method. the initialize(Bus bus) method is never invoked. like this: /** Be invoked, if the feature is defined in a endpoint. */ @Override public void initialize(Server server, Bus bus) { Service service = server.getEndpoint().getService(); addInterceptors(service); } /** Just for all the service */ @Override public void initialize(Bus bus) { addInterceptors(bus); } private void addInterceptors(InterceptorProvider provider) { AbstractPhaseInterceptor<Message> in = new EnabledSchemaValidationInterceptor(); provider.getInInterceptors().add(in); //provider.getInFaultInterceptors().add(in); AbstractPhaseInterceptor<Message> out = new DisabledSchemaValidationInterceptor(); provider.getOutInterceptors().add(out); //provider.getOutFaultInterceptors().add(out); } Relevant Classes: class EnabledSchemaValidationInterceptor extends AbstractPhaseInterceptor<Message> { public EnabledSchemaValidationInterceptor() { super(Phase.UNMARSHAL); addBefore(DocLiteralInInterceptor.class.getName()); } public void handleMessage(Message message) throws Fault { message.put("schema-validation-enabled",true); } } /** Do not validate a reponse. */ class DisabledSchemaValidationInterceptor extends AbstractPhaseInterceptor<Message> { public DisabledSchemaValidationInterceptor() { super(Phase.MARSHAL); addBefore(BareOutInterceptor.class.getName()); } public void handleMessage(Message message) throws Fault { message.put("schema-validation-enabled",false); } }
        Hide
        Dan Diephouse added a comment -

        Fixed in r20429. To enable validation add validationEnabled="true" to your cxf service element in your configuraiton. Validation is only supported on inbound.

        Show
        Dan Diephouse added a comment - Fixed in r20429. To enable validation add validationEnabled="true" to your cxf service element in your configuraiton. Validation is only supported on inbound.
        Hide
        Pablo Kraan added a comment -

        Is same fix applicable in 2.2.x? (CXF version=2.1.10)

        Show
        Pablo Kraan added a comment - Is same fix applicable in 2.2.x? (CXF version=2.1.10)
        Hide
        Dan Diephouse added a comment -

        Nope. This requires CXF 2.3.0

        Show
        Dan Diephouse added a comment - Nope. This requires CXF 2.3.0

          People

          • Assignee:
            Dan Diephouse
            Reporter:
            Puneet Gupta
          • Votes:
            1 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development