Home > database >  How to use a dynamic endpoint while using the validator component of apache camel?
How to use a dynamic endpoint while using the validator component of apache camel?

Time:12-01

I want to do an xml validation rest service using apache camel, however I want the path to the file to be dynamic but I was not able to do that:

package com.example.XMLValidator;

import org.apache.camel.builder.RouteBuilder;
import org.springframework.stereotype.Component;


import core.ErrorProcessor;

@Component
public class XMLValidatorRestService extends RouteBuilder{
    
        @Override
        public void configure() throws Exception {
            
            onException(Exception.class).handled(true)
            .process(new ErrorProcessor());
            
            

            rest("/xmlValidator/{xsdLocation}")
            .post()
            
            .to("direct:xmlValidator");
            
 
            from("direct:xmlValidator")
            .choice()
                .when(header("ebmName").isEqualTo("pers.marriage.ebm.marrInfo_1.0")).to("validator:${header.xsdLocation}")
      .log("${body}");
        }   
}

However this code is giving me the following error:

Cannot find resource: ${header.ebmName} for URI: ${header.ebmName}

This is the correct route: .to("validator:file:C:/ISF/trunk/ISFApplications/ServiceBusApplications/Applications/MarriageServiceBusApplication/MarriageSBProject/apps/pers.marriage/ebm/pers.marriage.ebm.marrInfo_1.0.xsd") So any idea how to make this path dynamic? Thank you

CodePudding user response:

Instead of to use toD. The toD is used for sending message to a dynamic endpoint.

Please refer : Camel docs

  • Related