【发布时间】:2022-01-06 04:05:23
【问题描述】:
我想使用 apache camel 进行 xml 验证休息服务,但是我希望文件的路径是动态的,但我无法做到:
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")
那么知道如何使这条路径动态化吗?谢谢
【问题讨论】:
标签: java eclipse spring-boot apache-camel