我正在尝试使用骆驼路线配置针对XSD验证传入的请求顺序(xml格式)。但是我不断收到下面的错误。谁能帮忙,我的代码在下面。
@Override
public void configure() {
//Other code
onException(ValidationException.class)
.to("{{jms.queue.invalidRequestQueue}}");
from("{{jms.queue.fulfilmentRequest}}")
.routeId(ROUTE_ID)
.to("validation:src/main/resources/xml/OrderCanonical.xsd", "{{jms.queue.fulfilmentRequest}}")
.transacted(PROPAGATION_REQUIRED)
.setHeader(ORDER_ID, xpath(XPATH_FOR_ORDERLINE).namespaces(nm).stringResult())
.beanRef("indiciaService", "getIndicias")
.choice()
.when(header(BOLPMessageHeaders.STATUS).isEqualTo(BOLPFulfilmentStatuses.FAILED))
.log(LoggingLevel.DEBUG, "Indicia call failed. Skipping call to Adobe.")
.to("{{jms.queue.fulfilmentResponse}}")
.otherwise()
.beanRef("adobePostageService", "generatePdf")
.setHeader(BOLPMessageHeaders.STATUS, simple(BOLPFulfilmentStatuses.FULFILLED))
.convertBodyTo(String.class)
.log(LoggingLevel.DEBUG, PRINT_HEADERS)
.log(LoggingLevel.DEBUG, PRINT_BODY)
.to("{{jms.queue.fulfilmentResponse}}");
}
这是错误:
Caused by: org.apache.camel.FailedToCreateRouteException: Failed to create route BOLPFulfilmentRoute at: >>> To[validator:src/main/resources/xml/OrderCanonical.xsd] <<< in route: Route(BOLPFulfilmentRoute)[[From[{{jms.queue.fulfilmentReque... because of Failed to resolve endpoint: validator://src/main/resources/xml/OrderCanonical.xsd due to: Cannot find resource: src/main/resources/xml/OrderCanonical.xsd in classpath for URI: src/main/resources/xml/OrderCanonical.xsd
最佳答案
我猜应该是validator
而不是validation
,对吗?
根据错误消息,找不到XSD文件。请尝试以下文件路径:
from("{{jms.queue.fulfilmentRequest}}")
.routeId(ROUTE_ID)
.to("validator:xml/OrderCanonical.xsd")
关于java - 针对Camel中的XSD验证订单,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/23411096/