BUG-2878: Add the XML declaration to every outgoing NETCONF message. 19/16919/1
authorGwenael Lambrouin <gwenael.lambrouin@b-com.com>
Fri, 20 Mar 2015 14:02:31 +0000 (15:02 +0100)
committerGwenael Lambrouin <gwenael.lambrouin@b-com.com>
Fri, 20 Mar 2015 14:04:36 +0000 (15:04 +0100)
Cisco routers expect that NETCONF messages are prefixed by the XML declaration
<?xml version="1.0" encoding="UTF-8"?>. Else, they close the NETCONF/SSH
connection and log an error such as "NETCONF-ERROR: parse error before hello seen".

This patch adds the XML declaration to every outgoing NETCONF message so that
Cisco routers accept NETCONF messages coming from the OpenDaylight controller.

This is a workaround for the sake of interoperability: according to RFC 6241,
the XML declaration is optional so Cisco routers should accept NETCONF messages
without XML declaration. See RFC 6241 section 3 "XML Considerations":

   A NETCONF message MAY begin with an XML declaration (see Section 2.8
   of [W3C.REC-xml-20001006]).

Change-Id: I04a8b61a8fcef6738e8a4552f0560aa319add014
Signed-off-by: Gwenael Lambrouin <gwenael.lambrouin@b-com.com>
opendaylight/netconf/netconf-netty-util/src/main/java/org/opendaylight/controller/netconf/nettyutil/handler/ThreadLocalTransformers.java

index a2039d6fe9b301e3a9f02c89a58b0689ebe5ab9d..cb7ff0d7fb837e326d178718003a56c1cfecb061 100644 (file)
@@ -47,7 +47,7 @@ final class ThreadLocalTransformers {
             }
 
             ret.setOutputProperty(OutputKeys.INDENT, "yes");
-            ret.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
+            ret.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "no");
             return ret;
         };