Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/oop/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Apache camel ApacheCamel和Xpath_Apache Camel - Fatal编程技术网

Apache camel ApacheCamel和Xpath

Apache camel ApacheCamel和Xpath,apache-camel,Apache Camel,我在Apache Camel中使用xpath表达式时遇到问题: Object obj = exchange.getIn().getBody(Document.class); String tag = XPathBuilder.xpath("name(//*)").resultType(String.class).evaluate(exchange.getContext(),obj,String.class); 但在退出时,我得到以下错误: org.apache.camel.TypeC

我在Apache Camel中使用xpath表达式时遇到问题:

  Object obj =  exchange.getIn().getBody(Document.class);
  String tag = XPathBuilder.xpath("name(//*)").resultType(String.class).evaluate(exchange.getContext(),obj,String.class);
但在退出时,我得到以下错误:

org.apache.camel.TypeConversionException:从类型:java.lang.String转换为所需类型:org.w3c.dom.Document,值为[Body is instance of java.io.InputStream]时出错,原因是org.xml.sax.SAXParseException:文件过早结束


有什么建议吗?

你的身体属于stream类型。在dsl中通过convertBodyTo(String.class)或在上面的xpath求值之前将主体转换为字符串。主体类型为stream。在dsl中通过convertBodyTo(String.class)或在上面的xpath求值之前将主体转换为字符串。