Fuse 6 is no longer supported
As of February 2025, Red Hat Fuse 6 is no longer supported. If you are using Fuse 6, please upgrade to Red Hat build of Apache Camel.Dieser Inhalt ist in der von Ihnen ausgewählten Sprache nicht verfügbar.
19.3. XPath Injection
Parameter binding annotation Link kopierenLink in die Zwischenablage kopiert!
Link kopierenLink in die Zwischenablage kopiert!
When using Apache Camel bean integration to invoke a method on a Java bean, you can use the
@XPath annotation to extract a value from the exchange and bind it to a method parameter.
For example, consider the following route fragment, which invokes the
credit method on an AccountService object:
from("queue:payments")
.beanRef("accountService","credit")
...
from("queue:payments")
.beanRef("accountService","credit")
...
The
credit method uses parameter binding annotations to extract relevant data from the message body and inject it into its parameters, as follows:
For more information about bean integration, see section "Bean Integration" in "Implementing Enterprise Integration Patterns".
Namespaces Link kopierenLink in die Zwischenablage kopiert!
Link kopierenLink in die Zwischenablage kopiert!
Table 19.1, “Predefined Namespaces for @XPath” shows the namespaces that are predefined for XPath. You can use these namespace prefixes in the
XPath expression that appears in the @XPath annotation.
| Namespace URI | Prefix |
|---|---|
http://www.w3.org/2001/XMLSchema | xsd |
http://www.w3.org/2003/05/soap-envelope | soap |
Custom namespaces Link kopierenLink in die Zwischenablage kopiert!
Link kopierenLink in die Zwischenablage kopiert!
You can use the
@NamespacePrefix annotation to define custom XML namespaces. Invoke the @NamespacePrefix annotation to initialize the namespaces argument of the @XPath annotation. The namespaces defined by @NamespacePrefix can then be used in the @XPath annotation's expression value.
For example, to associate the prefix,
ex, with the custom namespace, http://fusesource.com/examples, invoke the @XPath annotation as follows: