我想使用 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")
那么知道如何使這條路徑動態化嗎?謝謝
uj5u.com熱心網友回復:
而不是to使用toD。的toD用于發送訊息給一個動態端點。
請參考:Camel 檔案
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/370161.html
