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.Ce contenu n'est pas disponible dans la langue sélectionnée.
Chapter 10. Using XML Documents
Abstract
XML binding namespace Copier lienLien copié sur presse-papiers!
xformat to represent the XML binding extensions. Add the following line to your contracts:
xmlns:xformat ="http://cxf.apache.org/bindings/xformat"
xmlns:xformat ="http://cxf.apache.org/bindings/xformat"
Hand editing Copier lienLien copié sur presse-papiers!
- Add the namespace declaration to include the extensions defining the XML binding. See the section called “XML binding namespace”.
- Add a standard WSDL
bindingelement to your contract to hold the XML binding, give the binding a uniquename, and specify the name of the WSDLportTypeelement that represents the interface being bound. - Add an
xformat:bindingchild element to thebindingelement to identify that the messages are being handled as pure XML documents without SOAP envelopes. - Optionally, set the
xformat:bindingelement'srootNodeattribute to a valid QName. For more information on the effect of therootNodeattribute see the section called “XML messages on the wire”. - For each operation defined in the bound interface, add a standard WSDL
operationelement to hold the binding information for the operation's messages. - For each operation added to the binding, add the
input,output, andfaultchildren elements to represent the messages used by the operation.These elements correspond to the messages defined in the interface definition of the logical operation. - Optionally add an
xformat:bodyelement with a validrootNodeattribute to the addedinput,output, andfaultelements to override the value ofrootNodeset at the binding level.
rootNode attribute for the message to ensure that the message written on the wire is a valid, but empty, XML document.
XML messages on the wire Copier lienLien copié sur presse-papiers!
rootNode attribute on either the global xformat:binding element or on the individual message’s xformat:body elements. The rootNode attribute specifies the QName for the element that serves as the root node for the XML document generated by Apache CXF. When the rootNode attribute is not set, Apache CXF uses the root element of the message part as the root element when using doc style messages, or an element using the message part name as the root element when using rpc style messages.
rootNode attribute is not set the message defined in Example 10.1, “Valid XML Binding Message” would generate an XML document with the root element lineNumber.
Example 10.1. Valid XML Binding Message
rootNode attribute is not set. However, the message in Example 10.2, “Invalid XML Binding Message” would generate an invalid XML document.
Example 10.2. Invalid XML Binding Message
rootNode attribute specified in the XML binding, Apache CXF will generate an XML document similar to Example 10.3, “Invalid XML Document” for the message defined in Example 10.2, “Invalid XML Binding Message”. The generated XML document is invalid because it has two root elements: pairName and entryNum.
Example 10.3. Invalid XML Document
rootNode attribute, as shown in Example 10.4, “XML Binding with rootNode set” Apache CXF will wrap the elements in the specified root element. In this example, the rootNode attribute is defined for the entire binding and specifies that the root element will be named entrants.
Example 10.4. XML Binding with rootNode set
Example 10.5. XML Document generated using the rootNode attribute
Overriding the binding's rootNode attribute setting Copier lienLien copié sur presse-papiers!
rootNode attribute for each individual message, or override the global setting for a particular message, by using the xformat:body element inside of the message binding. For example, if you wanted the output message defined in Example 10.4, “XML Binding with rootNode set” to have a different root element from the input message, you could override the binding's root element as shown in Example 10.6, “Using xformat:body”.
Example 10.6. Using xformat:body