我们有一个支持netconf的路由器,我可以使用Mg-Soft客户端浏览器执行get / get-config操作。这是getConfig() -
的输出REQ:
<nc:get-config xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0">
<nc:source>
<nc:running/>
</nc:source>
</nc:get-config>
RESP:
<?xml version="1.0" encoding="utf-8"?>
<data xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
<configure xmlns="urn:nokia.com:sros:ns:yang:sr:conf">
<qos>
<sap-ingress>
.....
</data>
但是我无法使用tailf Netconf客户端执行相同的操作。 这是我的代码 -
public class Client {
public static void main(String args[]) throws JNCException,
ParserConfigurationException, SAXException, IOException {
DeviceUser deviceUser;
String deviceUserName = "user";
deviceUser = new DeviceUser(deviceUserName, "admin", "admin");
Device device = new Device("simulator", deviceUser, "10.135.16.13", 830);
device.connect(deviceUserName);
device.newSession(new Subscriber("simulator"), "mySession");
NetconfSession session = device.getSession("mySession");
NodeSet config = session.getConfig(NetconfSession.RUNNING);
String xmlString = config.toXMLString();
session.closeSession();
System.out.println(xmlString);
}
}
class Subscriber extends IOSubscriber {
String devName;
public static boolean rawMode = false;
Subscriber(String devName) {
super(rawMode);
this.devName = devName;
}
public void input(String data) {
System.out.println("RECV: " + data);
}
public void output(String data) {
System.out.println("SEND: " + data);
}
}
我在eclipse控制台中获得以下内容 -
SEND: <hello xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
<capabilities>
<capability>urn:ietf:params:netconf:base:1.0</capability>
</capabilities>
</hello>
RECV: <hello xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
<capabilities>
<capability>urn:ietf:params:netconf:base:1.0</capability>
<capability>urn:ietf:params:netconf:base:1.1</capability>
<capability>urn:ietf:params:netconf:capability:writable-running:1.0</capability>
<capability>urn:ietf:params:netconf:capability:candidate:1.0</capability>
<capability>urn:ietf:params:netconf:capability:validate:1.0</capability>
<capability>urn:ietf:params:netconf:capability:validate:1.1</capability>
<capability>urn:ietf:params:netconf:capability:startup:1.0</capability>
<capability>urn:ietf:params:netconf:capability:url:1.0?scheme=ftp,tftp,file</capability>
<capability>urn:ietf:params:netconf:capability:with-defaults:1.0?basic-mode=trim&also-supported=report-all</capability>
<capability>urn:ietf:params:xml:ns:netconf:base:1.0?module=ietf-netconf&revision=2011-06-01&features=writable-running,validate,startup,url&deviations=alu-netconf-deviations-r13</capability>
<capability>urn:alcatel-lucent.com:sros:ns:yang:netconf-deviations-r13?module=alu-netconf-deviations-r13&revision=2015-01-23</capability>
<capability>urn:alcatel-lucent.com:sros:ns:yang:cli-content-layer-r13?module=alu-cli-content-layer-r13&revision=2015-01-23</capability>
<capability>urn:alcatel-lucent.com:sros:ns:yang:conf-r13?module=alu-conf-r13&revision=2016-06-24</capability>
<capability>urn:alcatel-lucent.com:sros:ns:yang:conf-aaa-r13?module=alu-conf-aaa-r13&revision=2016-06-16</capability>
<capability>urn:alcatel-lucent.com:sros:ns:yang:conf-aa-r13?module=alu-conf-aa-r13&revision=2016-06-23</capability>
<capability>urn:alcatel-lucent.com:sros:ns:yang:conf-calltrace-r13?module=alu-conf-calltrace-r13&revision=2016-04-27</capability>
<capability>urn:alcatel-lucent.com:sros:ns:yang:conf-card-r13?module=alu-conf-card-r13&revision=2015-10-30</capability>
<capability>urn:alcatel-lucent.com:sros:ns:yang:conf-cflowd-r13?module=alu-conf-cflowd-r13&revision=2015-01-26</capability>
<capability>urn:alcatel-lucent.com:sros:ns:yang:conf-conn-prof-r13?module=alu-conf-conn-prof-r13&revision=2015-11-03</capability>
<capability>urn:alcatel-lucent.com:sros:ns:yang:conf-con-profvlan-r13?module=alu-conf-con-profvlan-r13&revision=2015-08-28</capability>
<capability>urn:alcatel-lucent.com:sros:ns:yang:conf-eth-cfm-r13?module=alu-conf-eth-cfm-r13&revision=2016-06-13</capability>
<capability>urn:alcatel-lucent.com:sros:ns:yang:conf-eth-ring-r13?module=alu-conf-eth-ring-r13&revision=2014-10-17</capability>
<capability>urn:alcatel-lucent.com:sros:ns:yang:conf-eth-tunnel-r13?module=alu-conf-eth-tunnel-r13&revision=2016-06-13</capability>
<capability>urn:alcatel-lucent.com:sros:ns:yang:conf-filter-r13?module=alu-conf-filter-r13&revision=2016-06-16</capability>
<capability>urn:alcatel-lucent.com:sros:ns:yang:conf-gmpls-tunnel-r13?module=alu-conf-gmpls-tunnel-r13&revision=2014-12-09</capability>
<capability>urn:alcatel-lucent.com:sros:ns:yang:conf-ifgrphandler-r13?module=alu-conf-ifgrphandler-r13&revision=2014-10-20</capability>
<capability>urn:alcatel-lucent.com:sros:ns:yang:conf-isa-r13?module=alu-conf-isa-r13&revision=2016-02-29</capability>
<capability>urn:alcatel-lucent.com:sros:ns:yang:conf-lag-r13?module=alu-conf-lag-r13&revision=2016-06-13</capability>
<capability>urn:alcatel-lucent.com:sros:ns:yang:conf-li-r13?module=alu-conf-li-r13&revision=2016-04-21</capability>
<capability>urn:alcatel-lucent.com:sros:ns:yang:conf-log-r13?module=alu-conf-log-r13&revision=2016-06-01</capability>
<capability>urn:alcatel-lucent.com:sros:ns:yang:conf-mcastmgmt-r13?module=alu-conf-mcastmgmt-r13&revision=2015-03-12</capability>
<capability>urn:alcatel-lucent.com:sros:ns:yang:conf-mirror-r13?module=alu-conf-mirror-r13&revision=2016-01-08</capability>
<capability>urn:alcatel-lucent.com:sros:ns:yang:conf-oam-pm-r13?module=alu-conf-oam-pm-r13&revision=2015-11-03</capability>
<capability>urn:alcatel-lucent.com:sros:ns:yang:conf-open-flow-r13?module=alu-conf-open-flow-r13&revision=2015-11-03</capability>
<capability>urn:alcatel-lucent.com:sros:ns:yang:conf-port-r13?module=alu-conf-port-r13&revision=2015-08-27</capability>
<capability>urn:alcatel-lucent.com:sros:ns:yang:conf-port-access-r13?module=alu-conf-port-access-r13&revision=2014-10-31</capability>
<capability>urn:alcatel-lucent.com:sros:ns:yang:conf-port-aps-r13?module=alu-conf-port-aps-r13&revision=2014-10-20</capability>
<capability>urn:alcatel-lucent.com:sros:ns:yang:conf-port-ethernet-r13?module=alu-conf-port-ethernet-r13&revision=2016-06-13</capability>
<capability>urn:alcatel-lucent.com:sros:ns:yang:conf-port-mbundle-r13?module=alu-conf-port-mbundle-r13&revision=2014-10-20</capability>
<capability>urn:alcatel-lucent.com:sros:ns:yang:conf-port-network-r13?module=alu-conf-port-network-r13&revision=2014-10-20</capability>
<capability>urn:alcatel-lucent.com:sros:ns:yang:conf-port-sonetsdh-r13?module=alu-conf-port-sonetsdh-r13&revision=2015-06-11</capability>
<capability>urn:alcatel-lucent.com:sros:ns:yang:conf-port-tdm-r13?module=alu-conf-port-tdm-r13&revision=2014-10-20</capability>
<capability>urn:alcatel-lucent.com:sros:ns:yang:conf-port-tdm-ds1-r13?module=alu-conf-port-tdm-ds1-r13&revision=2014-12-15</capability>
<capability>urn:alcatel-lucent.com:sros:ns:yang:conf-port-tdm-ds3-r13?module=alu-conf-port-tdm-ds3-r13&revision=2014-12-15</capability>
<capability>urn:alcatel-lucent.com:sros:ns:yang:conf-port-tdm-e1-r13?module=alu-conf-port-tdm-e1-r13&revision=2014-12-15</capability>
<capability>urn:alcatel-lucent.com:sros:ns:yang:conf-port-tdm-e3-r13?module=alu-conf-port-tdm-e3-r13&revision=2014-12-15</capability>
<capability>urn:alcatel-lucent.com:sros:ns:yang:conf-port-policy-r13?module=alu-conf-port-policy-r13&revision=2015-12-09</capability>
<capability>urn:alcatel-lucent.com:sros:ns:yang:conf-pxc-r13?module=alu-conf-pxc-r13&revision=2015-04-24</capability>
<capability>urn:alcatel-lucent.com:sros:ns:yang:conf-python-r13?module=alu-conf-python-r13&revision=2016-06-20</capability>
<capability>urn:alcatel-lucent.com:sros:ns:yang:conf-qos-r13?module=alu-conf-qos-r13&revision=2016-04-13</capability>
<capability>urn:alcatel-lucent.com:sros:ns:yang:conf-redundancy-r13?module=alu-conf-redundancy-r13&revision=2016-03-25</capability>
<capability>urn:alcatel-lucent.com:sros:ns:yang:conf-router-r13?module=alu-conf-router-r13&revision=2016-05-09</capability>
<capability>urn:alcatel-lucent.com:sros:ns:yang:conf-router-bgp-r13?module=alu-conf-router-bgp-r13&revision=2016-06-06</capability>
<capability>urn:alcatel-lucent.com:sros:ns:yang:conf-router-dhcps-r13?module=alu-conf-router-dhcps-r13&revision=2015-09-21</capability>
<capability>urn:alcatel-lucent.com:sros:ns:yang:conf-router-dhcp6-r13?module=alu-conf-router-dhcp6-r13&revision=2016-06-16</capability>
<capability>urn:alcatel-lucent.com:sros:ns:yang:conf-router-fspec-r13?module=alu-conf-router-fspec-r13&revision=2015-12-16</capability>
<capability>urn:alcatel-lucent.com:sros:ns:yang:conf-router-gmpls-r13?module=alu-conf-router-gmpls-r13&revision=2015-11-03</capability>
<capability>urn:alcatel-lucent.com:sros:ns:yang:conf-router-igmp-r13?module=alu-conf-router-igmp-r13&revision=2015-11-16</capability>
<capability>urn:alcatel-lucent.com:sros:ns:yang:conf-router-if-r13?module=alu-conf-router-if-r13&revision=2016-04-29</capability>
<capability>urn:alcatel-lucent.com:sros:ns:yang:conf-router-isis-r13?module=alu-conf-router-isis-r13&revision=2016-02-18</capability>
<capability>urn:alcatel-lucent.com:sros:ns:yang:conf-router-l2tp-r13?module=alu-conf-router-l2tp-r13&revision=2016-05-03</capability>
<capability>urn:alcatel-lucent.com:sros:ns:yang:conf-router-ldp-r13?module=alu-conf-router-ldp-r13&revision=2016-05-02</capability>
<capability>urn:alcatel-lucent.com:sros:ns:yang:conf-router-lmp-r13?module=alu-conf-router-lmp-r13&revision=2015-09-08</capability>
<capability>urn:alcatel-lucent.com:sros:ns:yang:conf-router-mccacpl-r13?module=alu-conf-router-mccacpl-r13&revision=2016-06-13</capability>
<capability>urn:alcatel-lucent.com:sros:ns:yang:conf-router-mld-r13?module=alu-conf-router-mld-r13&revision=2015-09-22</capability>
<capability>urn:alcatel-lucent.com:sros:ns:yang:conf-router-mpls-r13?module=alu-conf-router-mpls-r13&revision=2016-04-28</capability>
<capability>urn:alcatel-lucent.com:sros:ns:yang:conf-router-mpls-tp-r13?module=alu-conf-router-mpls-tp-r13&revision=2015-11-09</capability>
<capability>urn:alcatel-lucent.com:sros:ns:yang:conf-router-nat-r13?module=alu-conf-router-nat-r13&revision=2016-06-16</capability>
<capability>urn:alcatel-lucent.com:sros:ns:yang:conf-router-ogvalid-r13?module=alu-conf-router-ogvalid-r13&revision=2015-11-03</capability>
<capability>urn:alcatel-lucent.com:sros:ns:yang:conf-router-ospf-r13?module=alu-conf-router-ospf-r13&revision=2016-06-22</capability>
<capability>urn:alcatel-lucent.com:sros:ns:yang:conf-router-ospf3-r13?module=alu-conf-router-ospf3-r13&revision=2016-06-22</capability>
<capability>urn:alcatel-lucent.com:sros:ns:yang:conf-router-pcep-r13?module=alu-conf-router-pcep-r13&revision=2016-03-07</capability>
<capability>urn:alcatel-lucent.com:sros:ns:yang:conf-router-pim-r13?module=alu-conf-router-pim-r13&revision=2016-06-07</capability>
<capability>urn:alcatel-lucent.com:sros:ns:yang:conf-router-policy-r13?module=alu-conf-router-policy-r13&revision=2016-05-19</capability>
<capability>urn:alcatel-lucent.com:sros:ns:yang:conf-router-radprox-r13?module=alu-conf-router-radprox-r13&revision=2015-11-03</capability>
<capability>urn:alcatel-lucent.com:sros:ns:yang:conf-router-rip-r13?module=alu-conf-router-rip-r13&revision=2015-06-03</capability>
<capability>urn:alcatel-lucent.com:sros:ns:yang:conf-router-nhroute-r13?module=alu-conf-router-nhroute-r13&revision=2014-09-26</capability>
<capability>urn:alcatel-lucent.com:sros:ns:yang:conf-router-radvert-r13?module=alu-conf-router-radvert-r13&revision=2014-10-20</capability>
<capability>urn:alcatel-lucent.com:sros:ns:yang:conf-router-rsvp-r13?module=alu-conf-router-rsvp-r13&revision=2015-06-03</capability>
<capability>urn:alcatel-lucent.com:sros:ns:yang:conf-router-wlan-r13?module=alu-conf-router-wlan-r13&revision=2016-06-16</capability>
<capability>urn:alcatel-lucent.com:sros:ns:yang:conf-router-wpp-r13?module=alu-conf-router-wpp-r13&revision=2015-03-04</capability>
<capability>urn:alcatel-lucent.com:sros:ns:yang:conf-saa-r13?module=alu-conf-saa-r13&revision=2016-06-13</capability>
<capability>urn:alcatel-lucent.com:sros:ns:yang:conf-service-r13?module=alu-conf-service-r13&revision=2016-03-23</capability>
<capability>urn:alcatel-lucent.com:sros:ns:yang:conf-svc-apipe-r13?module=alu-conf-svc-apipe-r13&revision=2016-02-26</capability>
<capability>urn:alcatel-lucent.com:sros:ns:yang:conf-svc-cpipe-r13?module=alu-conf-svc-cpipe-r13&revision=2016-02-26</capability>
<capability>urn:alcatel-lucent.com:sros:ns:yang:conf-svc-cust-r13?module=alu-conf-svc-cust-r13&revision=2015-09-23</capability>
<capability>urn:alcatel-lucent.com:sros:ns:yang:conf-svc-dynsrv-r13?module=alu-conf-svc-dynsrv-r13&revision=2015-09-11</capability>
<capability>urn:alcatel-lucent.com:sros:ns:yang:conf-svc-egrmcgroup-r13?module=alu-conf-svc-egrmcgroup-r13&revision=2015-09-11</capability>
<capability>urn:alcatel-lucent.com:sros:ns:yang:conf-svc-epipe-r13?module=alu-conf-svc-epipe-r13&revision=2016-06-27</capability>
<capability>urn:alcatel-lucent.com:sros:ns:yang:conf-svc-fpipe-r13?module=alu-conf-svc-fpipe-r13&revision=2016-02-26</capability>
<capability>urn:alcatel-lucent.com:sros:ns:yang:conf-svc-ies-r13?module=alu-conf-svc-ies-r13&revision=2016-06-13</capability>
<capability>urn:alcatel-lucent.com:sros:ns:yang:conf-svc-ies-if-r13?module=alu-conf-svc-ies-if-r13&revision=2016-06-27</capability>
<capability>urn:alcatel-lucent.com:sros:ns:yang:conf-svc-ies-subif-r13?module=alu-conf-svc-ies-subif-r13&revision=2016-06-16</capability>
<capability>urn:alcatel-lucent.com:sros:ns:yang:conf-svc-ipfix-r13?module=alu-conf-svc-ipfix-r13&revision=2014-09-26</capability>
<capability>urn:alcatel-lucent.com:sros:ns:yang:conf-svc-ipipe-r13?module=alu-conf-svc-ipipe-r13&revision=2016-06-13</capability>
<capability>urn:alcatel-lucent.com:sros:ns:yang:conf-svc-nat-r13?module=alu-conf-svc-nat-r13&revision=2016-04-13</capability>
<capability>urn:alcatel-lucent.com:sros:ns:yang:conf-svc-sdp-r13?module=alu-conf-svc-sdp-r13&revision=2016-05-09</capability>
<capability>urn:alcatel-lucent.com:sros:ns:yang:conf-svc-template-r13?module=alu-conf-svc-template-r13&revision=2016-04-06</capability>
<capability>urn:alcatel-lucent.com:sros:ns:yang:conf-svc-upnp-r13?module=alu-conf-svc-upnp-r13&revision=2015-09-16</capability>
<capability>urn:alcatel-lucent.com:sros:ns:yang:conf-svc-vpls-r13?module=alu-conf-svc-vpls-r13&revision=2016-06-20</capability>
<capability>urn:alcatel-lucent.com:sros:ns:yang:conf-svc-vpls-igmp-r13?module=alu-conf-svc-vpls-igmp-r13&revision=2014-09-26</capability>
<capability>urn:alcatel-lucent.com:sros:ns:yang:conf-svc-vpls-macmo-r13?module=alu-conf-svc-vpls-macmo-r13&revision=2014-10-20</capability>
<capability>urn:alcatel-lucent.com:sros:ns:yang:conf-svc-vpls-macpr-r13?module=alu-conf-svc-vpls-macpr-r13&revision=2014-10-20</capability>
<capability>urn:alcatel-lucent.com:sros:ns:yang:conf-svc-vpls-meshs-r13?module=alu-conf-svc-vpls-meshs-r13&revision=2016-06-13</capability>
<capability>urn:alcatel-lucent.com:sros:ns:yang:conf-svc-vpls-mld-r13?module=alu-conf-svc-vpls-mld-r13&revision=2014-10-20</capability>
<capability>urn:alcatel-lucent.com:sros:ns:yang:conf-svc-vpls-pim-r13?module=alu-conf-svc-vpls-pim-r13&revision=2015-07-07</capability>
<capability>urn:alcatel-lucent.com:sros:ns:yang:conf-svc-vpls-sap-r13?module=alu-conf-svc-vpls-sap-r13&revision=2016-06-27</capability>
<capability>urn:alcatel-lucent.com:sros:ns:yang:conf-svc-vpls-split-r13?module=alu-conf-svc-vpls-split-r13&revision=2014-10-20</capability>
<capability>urn:alcatel-lucent.com:sros:ns:yang:conf-svc-vpls-spoke-r13?module=alu-conf-svc-vpls-spoke-r13&revision=2016-06-13</capability>
<capability>urn:alcatel-lucent.com:sros:ns:yang:conf-svc-vpls-spb-r13?module=alu-conf-svc-vpls-spb-r13&revision=2016-02-04</capability>
<capability>urn:alcatel-lucent.com:sros:ns:yang:conf-svc-vpls-stp-r13?module=alu-conf-svc-vpls-stp-r13&revision=2014-09-26</capability>
<capability>urn:alcatel-lucent.com:sros:ns:yang:conf-svc-vprn-r13?module=alu-conf-svc-vprn-r13&revision=2016-06-16</capability>
<capability>urn:alcatel-lucent.com:sros:ns:yang:conf-svc-vprn-bgp-r13?module=alu-conf-svc-vprn-bgp-r13&revision=2016-05-04</capability>
<capability>urn:alcatel-lucent.com:sros:ns:yang:conf-svc-vprn-dhcps-r13?module=alu-conf-svc-vprn-dhcps-r13&revision=2015-09-21</capability>
<capability>urn:alcatel-lucent.com:sros:ns:yang:conf-svc-vprn-dhcp6-r13?module=alu-conf-svc-vprn-dhcp6-r13&revision=2016-06-20</capability>
<capability>urn:alcatel-lucent.com:sros:ns:yang:conf-svc-vprn-fspec-r13?module=alu-conf-svc-vprn-fspec-r13&revision=2016-02-11</capability>
<capability>urn:alcatel-lucent.com:sros:ns:yang:conf-svc-vprn-igmp-r13?module=alu-conf-svc-vprn-igmp-r13&revision=2015-11-16</capability>
<capability>urn:alcatel-lucent.com:sros:ns:yang:conf-svc-vprn-if-r13?module=alu-conf-svc-vprn-if-r13&revision=2016-06-27</capability>
<capability>urn:alcatel-lucent.com:sros:ns:yang:conf-svc-vprn-isis-r13?module=alu-conf-svc-vprn-isis-r13&revision=2016-02-18</capability>
<capability>urn:alcatel-lucent.com:sros:ns:yang:conf-svc-vprn-l2tp-r13?module=alu-conf-svc-vprn-l2tp-r13&revision=2016-05-03</capability>
<capability>urn:alcatel-lucent.com:sros:ns:yang:conf-svc-vprn-mld-r13?module=alu-conf-svc-vprn-mld-r13&revision=2015-10-14</capability>
<capability>urn:alcatel-lucent.com:sros:ns:yang:conf-svc-vprn-nat-r13?module=alu-conf-svc-vprn-nat-r13&revision=2016-06-16</capability>
<capability>urn:alcatel-lucent.com:sros:ns:yang:conf-svc-vprn-nwif-r13?module=alu-conf-svc-vprn-nwif-r13&revision=2016-04-29</capability>
<capability>urn:alcatel-lucent.com:sros:ns:yang:conf-svs-vprn-ntp-r13?module=alu-conf-svs-vprn-ntp-r13&revision=2015-05-05</capability>
<capability>urn:alcatel-lucent.com:sros:ns:yang:conf-svc-vprn-ospf-r13?module=alu-conf-svc-vprn-ospf-r13&revision=2016-06-22</capability>
<capability>urn:alcatel-lucent.com:sros:ns:yang:conf-svc-vprn-ospf3-r13?module=alu-conf-svc-vprn-ospf3-r13&revision=2016-06-22</capability>
<capability>urn:alcatel-lucent.com:sros:ns:yang:conf-svc-vprn-pim-r13?module=alu-conf-svc-vprn-pim-r13&revision=2015-08-17</capability>
<capability>urn:alcatel-lucent.com:sros:ns:yang:conf-svc-vprn-ptp-r13?module=alu-conf-svc-vprn-ptp-r13&revision=2015-05-22</capability>
<capability>urn:alcatel-lucent.com:sros:ns:yang:conf-vprn-radprox-r13?module=alu-conf-vprn-radprox-r13&revision=2015-06-23</capability>
<capability>urn:alcatel-lucent.com:sros:ns:yang:conf-svc-vprn-rip-r13?module=alu-conf-svc-vprn-rip-r13&revision=2015-06-03</capability>
<capability>urn:alcatel-lucent.com:sros:ns:yang:conf-svc-vprn-ripng-r13?module=alu-conf-svc-vprn-ripng-r13&revision=2014-10-20</capability>
<capability>urn:alcatel-lucent.com:sros:ns:yang:conf-svc-vprn-radv-r13?module=alu-conf-svc-vprn-radv-r13&revision=2014-10-20</capability>
<capability>urn:alcatel-lucent.com:sros:ns:yang:conf-svc-vprn-srcad-r13?module=alu-conf-svc-vprn-srcad-r13&revision=2015-01-27</capability>
<capability>urn:alcatel-lucent.com:sros:ns:yang:conf-svc-vprn-spoke-r13?module=alu-conf-svc-vprn-spoke-r13&revision=2015-12-17</capability>
<capability>urn:alcatel-lucent.com:sros:ns:yang:conf-svc-vprn-subif-r13?module=alu-conf-svc-vprn-subif-r13&revision=2016-06-16</capability>
<capability>urn:alcatel-lucent.com:sros:ns:yang:conf-svc-vprn-wlan-r13?module=alu-conf-svc-vprn-wlan-r13&revision=2016-06-16</capability>
<capability>urn:alcatel-lucent.com:sros:ns:yang:conf-svc-vprn-wpp-r13?module=alu-conf-svc-vprn-wpp-r13&revision=2015-03-04</capability>
<capability>urn:alcatel-lucent.com:sros:ns:yang:conf-sflow-r13?module=alu-conf-sflow-r13&revision=2014-09-26</capability>
<capability>urn:alcatel-lucent.com:sros:ns:yang:conf-sfm-r13?module=alu-conf-sfm-r13&revision=2014-10-20</capability>
<capability>urn:alcatel-lucent.com:sros:ns:yang:conf-subscrmgmt-r13?module=alu-conf-subscrmgmt-r13&revision=2016-06-27</capability>
<capability>urn:alcatel-lucent.com:sros:ns:yang:conf-submgmt-ludb-r13?module=alu-conf-submgmt-ludb-r13&revision=2016-06-14</capability>
<capability>urn:alcatel-lucent.com:sros:ns:yang:conf-submgmt-wlangw-r13?module=alu-conf-submgmt-wlangw-r13&revision=2016-06-16</capability>
<capability>urn:alcatel-lucent.com:sros:ns:yang:conf-system-r13?module=alu-conf-system-r13&revision=2016-06-08</capability>
<capability>urn:alcatel-lucent.com:sros:ns:yang:conf-sys-pwrmgmt-r13?module=alu-conf-sys-pwrmgmt-r13&revision=2015-05-25</capability>
<capability>urn:alcatel-lucent.com:sros:ns:yang:conf-sys-ptp-r13?module=alu-conf-sys-ptp-r13&revision=2015-06-25</capability>
<capability>urn:alcatel-lucent.com:sros:ns:yang:conf-sys-sec-r13?module=alu-conf-sys-sec-r13&revision=2016-06-16</capability>
<capability>urn:alcatel-lucent.com:sros:ns:yang:conf-vrrp-r13?module=alu-conf-vrrp-r13&revision=2015-10-14</capability>
<capability>urn:alcatel-lucent.com:sros:ns:yang:conf-vsm-r13?module=alu-conf-vsm-r13&revision=2015-09-16</capability>
<capability>urn:alcatel-lucent.com:sros:ns:yang:types?module=alu-types&revision=2015-01-19</capability>
<capability>urn:nokia.com:sros:ns:yang:sr:conf?module=nokia-conf&revision=2016-01-01</capability>
<capability>urn:nokia.com:sros:ns:yang:sr:sros-yang-extensions?module=nokia-sros-yang-extensions&revision=2016-01-01</capability>
<capability>urn:nokia.com:sros:ns:yang:sr:types-filter?module=nokia-types-filter&revision=2016-01-01</capability>
<capability>urn:nokia.com:sros:ns:yang:sr:types-qos?module=nokia-types-qos&revision=2016-01-01</capability>
<capability>urn:nokia.com:sros:ns:yang:sr:types-services?module=nokia-types-services&revision=2016-01-01</capability>
<capability>urn:nokia.com:sros:ns:yang:sr:types-sros?module=nokia-types-sros&revision=2016-01-01</capability>
<capability>urn:nokia.com:sros:ns:yang:sr:major-release-14</capability>
</capabilities>
<session-id>52</session-id>
</hello>
SEND: <nc:rpc xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0" nc:message-id="1">
<nc:get-config>
<nc:source>
<nc:running/> </nc:source>
</nc:get-config>
</nc:rpc>
RECV: <?xml version="1.0" encoding="UTF-8"?>
<rpc-reply urn:ietf:params:xml:ns:netconf:base:1.0:message-id="1" xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
<rpc-error>
<error-type>rpc</error-type>
<error-tag>missing-attribute</error-tag>
<error-severity>error</error-severity>
<error-info>
<bad-element>message-id</bad-element>
<bad-element>rpc</bad-element>
</error-info>
<error-message>
Check that message-id attribute is present and less than 4096 characters
</error-message>
</rpc-error>
</rpc-reply>
[Fatal Error] :2:20: Attribute name "urn:ietf" associated with an element type "rpc-reply" must be followed by the ' = ' character.
[Fatal Error] :2:20: Attribute name "urn:ietf" associated with an element type "rpc-reply" must be followed by the ' = ' character.
org.xml.sax.SAXParseException; lineNumber: 2; columnNumber: 20; Attribute name "urn:ietf" associated with an element type "rpc-reply" must be followed by the ' = ' character.
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1239)
at com.tailf.jnc.YangXMLParser.parse(YangXMLParser.java:50)
at com.tailf.jnc.XMLParser.parse(XMLParser.java:154)
at com.tailf.jnc.NetconfSession.recv_rpc_reply(NetconfSession.java:1495)
at com.tailf.jnc.NetconfSession.recv_rpc_reply_data(NetconfSession.java:1472)
at com.tailf.jnc.NetconfSession.getConfig(NetconfSession.java:443)
at client.Client.main(Client.java:51)
Exception in thread "main" Parse error: parse error: org.xml.sax.SAXParseException; lineNumber: 2; columnNumber: 20; Attribute name "urn:ietf" associated with an element type "rpc-reply" must be followed by the ' = ' character.
at com.tailf.jnc.YangXMLParser.parse(YangXMLParser.java:54)
at com.tailf.jnc.XMLParser.parse(XMLParser.java:154)
at com.tailf.jnc.NetconfSession.recv_rpc_reply(NetconfSession.java:1495)
at com.tailf.jnc.NetconfSession.recv_rpc_reply_data(NetconfSession.java:1472)
at com.tailf.jnc.NetconfSession.getConfig(NetconfSession.java:443)
at client.Client.main(Client.java:51)
答案 0 :(得分:3)
你实际上似乎有两个问题,这两个问题似乎都不是你的错。来自JNC的get-config请求似乎格式不正确:message-id
属性应该在默认命名空间中,而不是在NETCONF消息命名空间中。
SEND: <nc:rpc xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0" nc:message-id="1">
<nc:get-config>
<nc:source>
<nc:running/> </nc:source>
</nc:get-config>
</nc:rpc>
实际应该是:
SEND: <nc:rpc xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="1">
<nc:get-config>
<nc:source>
<nc:running/> </nc:source>
</nc:get-config>
</nc:rpc>
第二个问题是您的服务器似乎无法处理此格式错误的请求 - 并且正在响应格式错误的消息(它甚至不是XML消息):
RECV: <?xml version="1.0" encoding="UTF-8"?>
<rpc-reply urn:ietf:params:xml:ns:netconf:base:1.0:message-id="1" xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
<rpc-error>
<error-type>rpc</error-type>
<error-tag>missing-attribute</error-tag>
<error-severity>error</error-severity>
<error-info>
<bad-element>message-id</bad-element>
<bad-element>rpc</bad-element>
</error-info>
<error-message>
Check that message-id attribute is present and less than 4096 characters
</error-message>
</rpc-error>
</rpc-reply>
应该回复:
RECV: <?xml version="1.0" encoding="UTF-8"?>
<rpc-reply nc:message-id="1" xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
<rpc-error>
<error-type>rpc</error-type>
<error-tag>missing-attribute</error-tag>
<error-severity>error</error-severity>
<error-info>
<bad-element>message-id</bad-element>
<bad-element>rpc</bad-element>
</error-info>
<error-message>
Check that message-id attribute is present and less than 4096 characters
</error-message>
</rpc-error>
</rpc-reply>
因为它应该逐字返回所有属性。否则,当没有message-id
属性的消息发送到服务器时,这将是标准行为。
下面的相关RFC4741文本(同样适用于RFC6241,NETCONF 1.1)。
&lt; rpc&gt; element有一个强制属性&#34; message-id&#34;,这是一个 通常由RPC的发送者选择的任意字符串 编码单调递增的整数。 RPC的接收者 不解码或解释此字符串,只是将其保存为 用作&#34; message-id&#34;任何结果&lt; rpc-reply&gt;中的属性 信息。例如:
<rpc message-id="101" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"> <some-method> <!-- method parameters here... --> </some-method> </rpc>
如果&lt; rpc&gt;中存在其他属性。元素,NETCONF peer必须在&lt; rpc-reply&gt;中不加修改地返回它们。元件。
如果&lt; rpc&gt;返回错误收到的元素没有 message-id属性。请注意,只有在这种情况下才是它 NETCONF对等体可以接受省略message-id属性 在&lt; rpc-reply&gt;中元件。
<rpc xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"> <get-config> <source> <running/> </source> </get-config> </rpc>
<rpc-reply xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"> <rpc-error> <error-type>rpc</error-type> <error-tag>missing-attribute</error-tag> <error-severity>error</error-severity> <error-info> <bad-attribute>message-id</bad-attribute> <bad-element>rpc</bad-element> </error-info> </rpc-error> </rpc-reply>
所以我相信你应该向设备制造商和JNC的创建者报告两个问题。
它与MG-SOFT客户端合作的原因是它发送了一个正确的message-id
属性,所以你的情况永远不会发生。