我怎样才能把一个字符串从 xpath 到一个 enricher url
How can I put a String from xpath to an enricher url
我需要一个 Enricher 的 GET 参数。我想使用 xpath 从消息正文中获取此参数。但它不想工作。我做错了什么?
.enrich("localhost/getArticle.php?ArticleNumber="+xpath("//POSITION/ARTICLENUMMER[@TYPE='IN']/text()"), new addArticleStrategy())
但是调用的URL是:
http://localhost/getArticle.php?ArticleNumber=XPath%3A+%2F%2FPOSITION%2FARTICLENUMMER%5B%40TYPE%3D%27IN%27%5D%2Ftext%28%29
如何从 xpath 中获取值,而不是 xpath 字符串?
谢谢
更新:
完整路线:
from("activemq:in")
.enrich("localhost/getArticle.php?ArticleNumber="+xpath("//POSITION/ARTICLENUMMER[@TYPE='IN']/text()"), new addArticleStrategy())
.to("file://C:/temp/")
更新 2:
我尝试评估:
from("activemq:in")
.enrich("localhost/getArticle.php?ArticleNumber="+xpath("//POSITION/ARTICLENUMMER[@TYPE='IN']/text()").evaluate(getContext(), body().convertToString()), new addArticleStrategy())
.to("file://C:/temp/")
但我得到错误:
No type converter available to convert from type: org.apache.camel.builder.ValueBuilder to the required type: org.w3c.dom.Document with value body
您不能将动态 URL 与 enrich 一起使用。尝试使用 recipientList 而不是
编辑:
我没试过(抱歉可能有错别字)但它应该是这样的
XPathBuilder articlexpath=xpath("//POSITION/ARTICLENUMMER[@TYPE='IN']/text()").resultType(String.class);
from("activemq:in")
.enrich("direct:getArticle", new addArticleStrategy())
.to("file://C:/temp/");
from("direct:getArticle")
.setHeader("ArticleNumber", articlexpath)
.recipientList(simple("localhost/getArticle.php?ArticleNumber=${header.ArticleNumber}"));
我需要一个 Enricher 的 GET 参数。我想使用 xpath 从消息正文中获取此参数。但它不想工作。我做错了什么?
.enrich("localhost/getArticle.php?ArticleNumber="+xpath("//POSITION/ARTICLENUMMER[@TYPE='IN']/text()"), new addArticleStrategy())
但是调用的URL是:
http://localhost/getArticle.php?ArticleNumber=XPath%3A+%2F%2FPOSITION%2FARTICLENUMMER%5B%40TYPE%3D%27IN%27%5D%2Ftext%28%29
如何从 xpath 中获取值,而不是 xpath 字符串?
谢谢
更新:
完整路线:
from("activemq:in")
.enrich("localhost/getArticle.php?ArticleNumber="+xpath("//POSITION/ARTICLENUMMER[@TYPE='IN']/text()"), new addArticleStrategy())
.to("file://C:/temp/")
更新 2: 我尝试评估:
from("activemq:in")
.enrich("localhost/getArticle.php?ArticleNumber="+xpath("//POSITION/ARTICLENUMMER[@TYPE='IN']/text()").evaluate(getContext(), body().convertToString()), new addArticleStrategy())
.to("file://C:/temp/")
但我得到错误:
No type converter available to convert from type: org.apache.camel.builder.ValueBuilder to the required type: org.w3c.dom.Document with value body
您不能将动态 URL 与 enrich 一起使用。尝试使用 recipientList 而不是
编辑:
我没试过(抱歉可能有错别字)但它应该是这样的
XPathBuilder articlexpath=xpath("//POSITION/ARTICLENUMMER[@TYPE='IN']/text()").resultType(String.class);
from("activemq:in")
.enrich("direct:getArticle", new addArticleStrategy())
.to("file://C:/temp/");
from("direct:getArticle")
.setHeader("ArticleNumber", articlexpath)
.recipientList(simple("localhost/getArticle.php?ArticleNumber=${header.ArticleNumber}"));