We have a netconf enabled router and I am able to perform get/get-config operations using Mg-Soft client browser. This is the output of 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>
But I am unable to perform the same operation using tailf Netconf client.
Here is my code -
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);
}
}
I am getting the following in the eclipse console -
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)
You actually seem to have two problems, neither of which appear to be your fault. The get-config request from JNC seems to be malformed: message-id attribute should be in the default namespace, not in NETCONF message namespace.
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>
Should actually be:
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>
The second problem is your server, which appears to be unable to handle this malformed request - and is responding with a malformed message (it is not even an XML message):
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>
It should be responding with:
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>
since it is supposed to return all attributes verbatim. Otherwise, this would be standard behavior when a message without a message-id attribute is sent to a server.
Relevant RFC4741 text below (the same applies to RFC6241, NETCONF 1.1).
Section 4.1:
The <rpc> element has a mandatory attribute "message-id", which is an
arbitrary string chosen by the sender of the RPC that will commonly
encode a monotonically increasing integer. The receiver of the RPC
does not decode or interpret this string but simply saves it to be
used as a "message-id" attribute in any resulting <rpc-reply>
message. For example:
<rpc message-id="101"
xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
<some-method>
<!-- method parameters here... -->
</some-method>
</rpc>
If additional attributes are present in an <rpc> element, a NETCONF
peer MUST return them unmodified in the <rpc-reply> element.
Section 4.3
An error is returned if an <rpc> element is received without a
message-id attribute. Note that only in this case is it
acceptable for the NETCONF peer to omit the message-id attribute
in the <rpc-reply> element.
<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>
So I believe you should be reporting two issues to both the maker of the device and to creators of JNC.
The reason it is working with the MG-SOFT client is that it sends a proper message-id attribute, so your case never happens.
Related
I am trying to read the clob which is basically XML from Oracle DB and populate in AngularJS UI Grid.
I am doing the same with JSON and is working perfectly fine.
JSON response from backend
{"events":{"ORDER_NO":"BBY01-100000709660","ORDER_HEADER_KEY":"2020040811522311790606 ","CREATETS":"2020-04-08 11:52:47","TMPLT_NM":"EOMS_0194 ","EMAIL_XML":"<email CommunicationType=\"Email\" SourceSystem=\"OMS\" TemplatePageZone=\"\" brand=\"BESTBUY\" channel=\"BESTBUY\" emailAddr=\"test.tester#bestbuy.com\" template=\"EOMS_0178_TEST\">"" <name firstName=\"Test\" lastName=\"\" middleInitial=\"\"/>"" <order ATGID=\"ATG28268080246\" IsSuppressRequired=\"Y\" LoggedInFlag=\"Y\" LoyaltyID=\"0160140134\" OrderName=\"MSFTAllAccess\" PartyID=\"123456\" PriorityNumber=\"160140134\" customerPhoneNo=\"6515554321\" hasActivatedDevice=\"N\" orderDate=\"01/28/2020\" orderHeaderKey=\"2020012813423582265743\" orderIdATG=\"BBY01-1MT2010012802\" orderStatusLinkDisplayFlag=\"Y\" orderTotal=\"0.00\" orderTotalMinusCoupons=\"0.00\" partnerID=\"\" partnerOrderNo=\"MAV513281qweq1\" salesSource=\"BBYC\" shippingTotal=\"0.00\" taxTotal=\"0.00\">"" <creditCard cardType=\"\" number=\"\"/>"" <digitalCoupons digitalCouponTotal=\"0.00\"/>"" <lineItems>"" <lineItem CustPromiseDate=\"02/26/2020\" CustPromiseType=\"InHandDate\" availabilityMsg=\"\" beginEstArrivalDate=\"02/24/2020\" conditionVariableOne=\"\" conditionVariableTwo=\"\" description=\"Microsoft Surface Pro 3 12 Intel Core i7 256GB Silver\" endEstArrivalDate=\"02/26/2020\" expectedShipDays=\"\" format=\"\" giftPackaging=\"N\" inHandDate=\"02/26/2020\" itemID=\"\" itemShortDesc=\"Microsoft Surface Pro 3 12 Intel Core i7 256GB Silver\" lineItemProductTotal=\"0.00\" lineItemShippingCost=\"0.00\" merchClass=\"\" modelNo=\"1000186097\" orderLineKey=\"2020021911334791500160\" oversizeFlag=\"\" pickupDate=\"\" preOrder=\"\" primeLine=\"1\" productLine=\"6.403.635\" quantity=\"1\" releaseDate=\"\" reshipReasonCode=\"RESHIP_DAMAGED_ITEM\" shipDate=\"\" shippingMethod=\"\" signatureRequiredFlag=\"N\" sku=\"9248206\" status=\"\" subLine=\"1\" tax=\"0.00\" total=\"0.00\" unitPrice=\"0.00\" unitShippingCost=\"0.00\">"" <shippingAddr city=\"RICHFIELD\" line1=\"1000 W 78TH ST\" line2=\"\" state=\"MN\" zip=\"55423\">"" <name firstName=\"Test\" lastName=\"Tester\" middleInitial=\"\"/>"" </shippingAddr>"" <allowance allowanceAmt=\"0.00\" reason=\"\"/>"" <return date=\"\" lineQty=\"\" lineTotal=\"0.00\" productCredit=\"0.00\" reason=\"\" restockingFee=\"0.00\" shippingCredit=\"0.00\" taxCredit=\"0.00\"/>"" <cancel backOrderExtendedXNumDays=\"\" reason=\"\"/>"" <ros actualDeliveryDate=\"\" pickupDate=\"\"/>"" <store storeName=\"\" storeNum=\"\"/>"" <psp plan=\"\"/>"" <carriers>"" <carrier los=\"\" name=\"\" quantity=\"\" trackingNum=\"\"/>"" </carriers>"" </lineItem>"" </lineItems>"" <makeGood makeGoodFlag=\"N\"/>"" </order>"" <account atgProfileId=\"\" cirisID=\"\" info=\"\" password=\"\"/>"" <comments/>""</email>"}}
Whenever i am trying to read the values it is throwing exception
Unexpected string in JSON at position 372
at JSON.parse (<anonymous>)
Below is the AJAX response code:
$http.get(url).then(function(response) {
if(response.data.events == null || response.data.events == undefined ||
response.data.events == "undefined"){
$("#loader1").hide();
$scope.close = true;
$scope.responseMessage = "";
$scope.gridOptions1.data.length=0;
$scope.errorMessage = "Order not found!!!!";
}else{
console.log("1");
$("#loader1").hide();
var responseNew = JSON.stringify(response.data.events);
$scope.gridOptions1.data = responseNew;
$scope.mySelectedRows = $scope.gridApi.selection.getSelectedRows();
$scope.close = true;
$scope.errorMessage = "";
$scope.responseMessage = "Order details fetched successfully";
}
}, function(response) {
$("#loader1").hide();
$scope.close = true;
$scope.responseMessage = "";
$scope.gridOptions.data.length=0;
$scope.gridOptions1.data.length=0;
});
There's one double quote extra here:
Parse error on line 1:
...\"EOMS_0178_TEST\">"" <name firstName...
-----------------------^
Expecting 'EOF', '}', ':', ',', ']', got 'STRING'
use JSON.parse instead of JSON.stringify. The response you're getting from back-end (the one you mentioned above) is already a stringified JSON, you have to parse it out to read the values.
The above issue waswhile storing the xml in DB. since the new elements had spaces in between. it was considering that as a string and was getting appended with double quotes in JSON.
Hello I have below SOAP reponse.
`
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<GetWeatherResponse xmlns="http://www.webserviceX.NET">
<GetWeatherResult><![CDATA[<?xml version="1.0" encoding="utf-16"?>
<CurrentWeather>
<Location>Cape Town, Cape Town International Airport, South Africa (FACT) 33-59S 018-36E 0M</Location>
<Time>Jun 04, 2016 - 05:00 AM EDT / 2016.06.04 0900 UTC</Time>
<Wind> from the SE (130 degrees) at 21 MPH (18 KT):0</Wind>
<Visibility> greater than 7 mile(s):0</Visibility>
<SkyConditions> mostly clear</SkyConditions>
<Temperature> 60 F (16 C)</Temperature>
<DewPoint> 44 F (7 C)</DewPoint>
<RelativeHumidity> 55%</RelativeHumidity>
<Pressure> 30.39 in. Hg (1029 hPa)</Pressure>
<Status>Success</Status>
</CurrentWeather>]]></GetWeatherResult>
</GetWeatherResponse>
</soap:Body>
</soap:Envelope>"`
for the following request: http://www.webservicex.net/globalweather.asmx.
I want to read XML Data in above response using script. but it is giving null.
I have tried script as below
def groovyUtils = new com.eviware.soapui.support.GroovyUtils(context)
def holder = groovyUtils.getXmlHolder(messageExchange.responseContent)
holder.namespaces["ns"] = "http://www.webserviceX.NET/" def
weatherinfo= holder.getNodeValue("//ns:GetWeatherResult/text()")
log.info weatherinfo
bit Instead of getting above reponse I am getting NULL. I have read the SOAPUI documentation on CDATA but its not working.
I got answer. It was just one extra slash in namespace that was giving me null.
Both the below scripts are working now.
> def respXmlHolder = new
> com.eviware.soapui.support.XmlHolder(messageExchange.getResponseContentAsXml())
> respXmlHolder.namespaces["ns1"] ="http://www.webserviceX.NET" def
> CDATAXml= respXmlHolder.getNodeValue("//ns1:GetWeatherResult/text()")
> log.info CDATAXml
def groovyUtils = new com.eviware.soapui.support.GroovyUtils(context)
def holder = groovyUtils.getXmlHolder(messageExchange.responseContent)
holder.namespaces["ns"] = "http://www.webserviceX.NET"
def weatherinfo= holder.getNodeValue("//ns:GetWeatherResult/text()")
log.info weatherinfo
I will try to explain that briefly.
I need to include a new field called shipToStoreGLN inside an Axis request implemented long ago using a WSDL descriptor.
It has to appear in the path OrderRequest -> PedidosIn(OrdersIn) -> Pedido (Order)-> Cabecera (Header)
I tryed to add the field like any other field is added, but it doesn't work, it doesn't appear in the final request.
Which is even stranger is that there's another field called shipToStore which has the added added to the class but it's not added in the types description but it appears on the final request.
Can someone tell me how to add that field, and if possible, explain why that other field appears?
I'll paste the code, a stub of how the request has to look like and how does it looks right now.
Thanks to everybody.
The relevant code of the class OrderRequestPedidosInPedidoCabecera.java (I'm not able to copy the full java source because it's too long):
//The getters and setters
public java.lang.String getShipToStoreGLN() {
return shipToStoreGLN;
}
public void setShipToStoreGLN(java.lang.String shipToStoreGLN) {
this.shipToStoreGLN = shipToStoreGLN;
}
//Applying it to the type descriptor
elemField = new org.apache.axis.description.ElementDesc();
elemField.setFieldName("shipToStoreGLN");
elemField.setXmlName(new javax.xml.namespace.QName("http://tempuri.org/GatewayService/", "shipToStoreGLN"));
elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string"));
elemField.setMinOccurs(0);
elemField.setNillable(false);
typeDesc.addFieldDesc(elemField);
The Stub on how the request has to look like:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:gat="http://tempuri.org/GatewayService/">
<soapenv:Header/>
<soapenv:Body>
<gat:OrderRequest>
<gat:PedidosIn>
<gat:Identificacion>
<gat:IdUsuario>?</gat:IdUsuario>
<gat:Password>?</gat:Password>
</gat:Identificacion>
<gat:Pedido>
<gat:Cabecera>
<gat:NumeroPedido>?</gat:NumeroPedido>
<gat:shipToStore>?</gat:shipToStore>
<gat:shipToStoreGLN>?</gat:shipToStoreGLN>
<gat:FechaPedido>?</gat:FechaPedido>
<gat:Facturacion>
<gat:Nombre>?</gat:Nombre>
<gat:Apellidos>?</gat:Apellidos>
<gat:Direccion>?</gat:Direccion>
<gat:CodigoPostal>?</gat:CodigoPostal>
<gat:Poblacion>?</gat:Poblacion>
<gat:Provincia>?</gat:Provincia>
<gat:NIF>?</gat:NIF>
<gat:Telefono>?</gat:Telefono>
</gat:Facturacion>
<gat:Entrega>
<gat:Nombre>?</gat:Nombre>
<gat:Apellidos>?</gat:Apellidos>
<gat:Direccion>?</gat:Direccion>
<gat:CodigoPostal>?</gat:CodigoPostal>
<gat:Poblacion>?</gat:Poblacion>
<gat:Provincia>?</gat:Provincia>
<gat:NIF>?</gat:NIF>
<gat:Telefono>?</gat:Telefono>
</gat:Entrega>
<gat:Total>?</gat:Total>
<gat:Email>?</gat:Email>
<gat:CodigoTrackingTrans>?</gat:CodigoTrackingTrans>
<gat:NumeroExpedicion>?</gat:NumeroExpedicion>
<gat:CodigoRuta>?</gat:CodigoRuta>
<gat:NombreRuta>?</gat:NombreRuta>
<gat:CodigoAgenciaDestino>?</gat:CodigoAgenciaDestino>
<gat:NombreAgenciaDestino>?</gat:NombreAgenciaDestino>
</gat:Cabecera>
<gat:Lineas>
<!--Zero or more repetitions:-->
<gat:Linea>
<gat:IdPedidoLinea>?</gat:IdPedidoLinea>
<gat:Referencia>?</gat:Referencia>
<gat:ReferenciaMS>?</gat:ReferenciaMS>
<gat:Posicion>?</gat:Posicion>
<gat:Cantidad>?</gat:Cantidad>
<gat:Descripcion>?</gat:Descripcion>
<gat:PrecioUnitario>?</gat:PrecioUnitario>
<gat:Total>?</gat:Total>
</gat:Linea>
</gat:Lineas>
</gat:Pedido>
</gat:PedidosIn>
</gat:OrderRequest>
</soapenv:Body>
</soapenv:Envelope>
How the request looks like now:
<soapenv:Body xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<OrderRequest xmlns="http://tempuri.org/GatewayService/">
<PedidosIn>
<Identificacion>
<IdUsuario>MMKTTEST</IdUsuario>
<Password>H23mLu3RieDr</Password>
</Identificacion>
<Pedido>
<Cabecera>
<NumeroPedido>000123657</NumeroPedido>
<FechaPedido>20140911 122523</FechaPedido>
<CodigoTiendaFacturacion>E290</CodigoTiendaFacturacion>
<CodigoTiendaEntrega>E290</CodigoTiendaEntrega>
<Facturacion>
<Nombre>Cristina</Nombre>
<Apellidos>Franco</Apellidos>
<Direccion>barcelona,gggg gggg</Direccion>
<CodigoPostal>08022</CodigoPostal>
<Poblacion>BARCELONA</Poblacion>
<Provincia>BARCELONA</Provincia>
<CodigoProvincia>08</CodigoProvincia>
<NIF>52173198K</NIF>
<Telefono>677714997</Telefono>
<pais>es</pais>
</Facturacion>
<Entrega>
<Nombre>MEDIA MARKT DIAGONAL MAR-BARCELONA VIDEO-TV-HIFI-E</Nombre>
<Apellidos>LEKTRO-COMPUTER-FOTO, S.A </Apellidos>
<Direccion>C.C DIAGONAL MAR AVDA DIAGONAL Nº3, planta B local 14000</Direccion>
<CodigoPostal>08019</CodigoPostal>
<Poblacion>BARCELONA</Poblacion>
<Provincia>BARCELONA</Provincia>
<NIF/>
<Telefono>934857200</Telefono>
<direccion1>C.C DIAGONAL MAR AVDA DIAGONAL Nº3, planta B local 14000</direccion1>
<direccion2/>
<direccion3/>
</Entrega>
<Total>219.0</Total>
<Email>crisfrancob#gmail.com</Email>
<CodigoTrackingTrans/>
<NumeroExpedicion/>
<CodigoRuta/>
<NombreRuta/>
<CodigoAgenciaDestino/>
<NombreAgenciaDestino/>
<shipToStore>1</shipToStore>
</Cabecera>
<Lineas>
<Linea>
<IdPedidoLinea>0</IdPedidoLinea>
<Referencia>B99B329</Referencia>
<ReferenciaMS>1148842</ReferenciaMS>
<ReferenciaUni/>
<Posicion>1</Posicion>
<Cantidad>1.0</Cantidad>
<Descripcion>GF EN210 SILENT/DI/1GD3/V2 CTLR 1GB DDR3 PCI-E DVI-I HDMI IN</Descripcion>
<PrecioUnitario>0.0</PrecioUnitario>
<Total>0.0</Total>
</Linea>
</Lineas>
</Pedido>
</PedidosIn>
</OrderRequest>
</soapenv:Body>
I was setting a null on shipToStoreGLN field. Now I know you can't set a null and expect the XML tag to appear.
I want to parse a log4j generated xml log. Within the xml is a node with a throwable (if any). This (multiline, tabbed) text is encapsulated in a CDATA tag.
This is an excerpt of the whole file:
<log4j:event logger="org.codehaus.groovy.grails.web.errors.GrailsExceptionResolver" timestamp="1330083921521" level="ERROR" thread="http-8080-1">
<log4j:message><![CDATA[Exception occurred when processing request: [GET] /test/log/show
Stacktrace follows:]]></log4j:message>
<log4j:throwable><![CDATA[org.xml.sax.SAXParseException: XML document structures must start and end within the same entity.
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1231)
at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:522)
at test.LogController$_closure2.doCall(LogController.groovy:21)
at test.LogController$_closure2.doCall(LogController.groovy)
at java.lang.Thread.run(Thread.java:662)
]]></log4j:throwable>
</log4j:event>
I parse it with groovys XmlParser:
def parser = new XmlParser(false, false).parse(new File("stack.log"))
return parser.'log4j:event'.collect { l ->
LogEntry entry = new LogEntry()
entry.with {
level = l.'#level'
message = l.'log4j:message'.text()
thread = l.'#thread'
logger = l.'#logger'
timestamp = new Date(l.'#timestamp' as long)
throwable = l.'log4j:throwable'?.text() ?: ''
}
entry
}
The 'throwable' field contains all the text but without CR/LF.
Does anybody know how to cope with that?
Thanks in advcance...
Hate to just throw code at you, but it seems to work as expected and returns the CRLFs
def xml = '''<log>
| <log4j:event logger="org.codehaus.groovy.grails.web.errors.GrailsExceptionResolver" timestamp="1330083921521" level="ERROR" thread="http-8080-1">
| <log4j:message><![CDATA[Exception occurred when processing request: [GET] /test/log/show
|Stacktrace follows:]]></log4j:message>
| <log4j:throwable><![CDATA[org.xml.sax.SAXParseException: XML document structures must start and end within the same entity.
| at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1231)
| at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:522)
| at test.LogController$_closure2.doCall(LogController.groovy:21)
| at test.LogController$_closure2.doCall(LogController.groovy)
| at java.lang.Thread.run(Thread.java:662)
|]]></log4j:throwable>
| </log4j:event>
|</log>'''.stripMargin()
class LogEntry {
def level
def message
def thread
def logger
def timestamp
def throwable
String toString() {
"""EVENT:
| level : $level
| message : $message
| thread : $thread
| logger : $logger
| ts : $timestamp
| thrown : $throwable""".stripMargin()
}
}
def parser = new XmlParser(false, false).parseText( xml )
def entries = parser.'log4j:event'.collect { event ->
new LogEntry().with {
level = event.#level
message = event.'log4j:message'.text()
thread = event.#thread
logger = event.#logger
timestamp = new Date( event.#timestamp as long )
throwable = event.'log4j:throwable'?.text() ?: ''
it
}
}
entries.each {
println it
}
That prints:
EVENT:
level : ERROR
message : Exception occurred when processing request: [GET] /test/log/show
Stacktrace follows:
thread : http-8080-1
logger : org.codehaus.groovy.grails.web.errors.GrailsExceptionResolver
ts : Fri Feb 24 11:45:21 GMT 2012
thrown : org.xml.sax.SAXParseException: XML document structures must start and end within the same entity.
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1231)
at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:522)
at test.LogController$_closure2.doCall(LogController.groovy:21)
at test.LogController$_closure2.doCall(LogController.groovy)
at java.lang.Thread.run(Thread.java:662)
Which has CRLF chars in it where they are supposed to be...
This is with Groovy 1.8.6 btw... What version are you using? Can you upgrade and try again?
The xml standard calls for white space to be normalized during the parse.
I'm not sure, but the parser may have a setting to override this behavior. Otherwise, you could pre-process the file, replacing line endings inside c data sections with their xml entity equivalents, and then parse it.
I have the below xml, Updated added "symptoms"
<EBF>
<EBFINFO>
<EBFNUM>EBF262323</EBFNUM>
<RELEASEDATETIME>May 06, 2011</RELEASEDATETIME>
<SYMPTOMS>
<br> INFA252994 - 910 : While running concurrent session Workflow manager hangs and workflow monitor does not respond</br>
<br> INFA262323 - 910 : pmcmd, pmdtm and all LM clients on Windows fail to connect to IS when IPv6 is installed but all IPv6 interfaces are disabled</br>
</SYMPTOMS>
<FILES>
<FILE>
<PATH>H:\EBF262323\EBF262323_Client_Installer_win32_x86\EBFs\clients\PmClient\client\bin\ACE.dll_bak</PATH>
<CHECKSUM>303966974</CHECKSUM>
<AFFECTEDFILES>
<CHECKSUM>3461283269</CHECKSUM>
<PATH>C:\clients\PmClient\CommandLineUtilities\PC\server\bin\ACE.dll</PATH>
<PATH>C:\clients\PmClient\client\bin\ACE.dll</PATH>
</AFFECTEDFILES>
</FILE>
</FILES>
<NOTES>
</NOTES>
</EBFINFO>
</EBF>
Note: In the above xml ebf\enfinfo\files\file\affectedfiles\path and ebf\enfinfo\files\file can be one or more
which I am parsing and generating another xml out of it
def records = new XmlParser().parseText(rs)
csm.ebfHistory(){
records.EBFINFO.each{
ebfHistory_info(num:it.EBFNUM.text(),
release_date_time:it.RELEASEDATETIME.text()
){
it.FILES.FILE.each{ //says Exception in thread "main" java.lang.NullPointerException: Cannot get property 'FILES' on null object
ebfHistory_fileinfo(file_path:it.PATH.text(),
file_checksum:it.CHECKSUM.text()
){
ebfHistory_fileinfo_affectedfiles(
afile_checksum:it.CHECKSUM.text(),
afile_path:it.PATH.text()
)
}
}
}
}
}
something like below
<ebfHistory>
<ebfHistory_info num="EBF262323",release_date_time="May 06, 2011">
<ebfHistory_fileinfo file_checksum="303966974">
<ebfHistory_fileinfo_affectedfiles afile_checksum="3461283269">
<path>C:\clients\PmClient\CommandLineUtilities\PC\server\bin\ACE.dll</path>
<path>C:\clients\PmClient\client\bin\ACE.dll</path>
</ebfHistory_fileinfo_affectedfiles>
</ebfHistory_fileinfo>
</ebfHistory_info>
</ebfHistory>
but instead I get Exception in thread "main" java.lang.NullPointerException: Cannot get property 'FILES' on null object where am i going wrong? Please help somebody. Thanks
Updated code (working)
def records = new XmlParser().parseText(rs)
csm.ebfHistory(){
records.EBFINFO.each{ ebfinfo ->
ebfHistory_info(num:ebfinfo.EBFNUM.text(),
release_date_time:ebfinfo.RELEASEDATETIME.text())
{
ebfinfo.SYMPTOMS.br.each{
ebfHistory_symptom(name:it.text())
}
}
}
ebfHistory_dump(rs){
"${rs}"
}
}
The it no longer refers to each EBFINFO, because you are in another closure--the ebfHistory_info closure.
Instead, explicitly name the EBFINFO object:
records.EBFINFO.each { ebfinfo -> // <-- Give it a name
ebfHistory_info(num:it.EBFNUM.text(),
release_date_time:it.RELEASEDATETIME.text()) {
ebfinfo.FILES.FILE.each { // <-- Use the name here
Same thing in the ebfHistory_fileinfo_affectedfiles parameters.