javaapache-cameljbossfuse

How to Validate Input Request against the WSDL in apache Camel


I am pretty new to apache camel, and hence i want to understand how can I validate my input message against the wsdl in apache camel, here is the code that i am trying:

 from("direct:Validation").log("Trying Validation Now...")
            .doTry().to("validator:wsdl/validation2.xsd")
            .log("${body}").to("direct:Response")
            .log(" response on Success")
            .doCatch(ValidationException.class)
            .log(LoggingLevel.ERROR, "Error occured in validation").end()

Solution

  • While configuring your camel-cxf endpoint you can provide property "schema-validation-enabled=true" using "properties" parameter. It will turns on SchemaValidation for messages. More info here

    Edit: according your cxf version, value of schema-validation-enabled can be different, read documentation.