如何在使用apachecamel的验证器组件时使用动态端点



我想使用apachecamel做一个xml验证rest服务,但我希望文件的路径是动态的,但我无法做到:

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}");
}   
}

然而,这个代码给了我以下错误:

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

这是正确的路线:.to("validator:file:C:/ISF/trunk/ISFApplications/ServiceBusApplications/Applications/MarriageServiceBusApplication/MarriageSBProject/apps/pers.marriage/ebm/pers.marriage.ebm.marrInfo_1.0.xsd")那么,你知道如何让这条路充满活力吗?谢谢

使用to而不是toDtoD用于向动态端点发送消息。

请参阅:Camel docs

最新更新