Help us improve your experience.

Let us know what you think.

Do you have time for a two-minute survey?

 
 

Request Operational Information Using the Junos XML Protocol

A Junos XML protocol client application can use Junos XML request tags to request operational information from Junos devices.

A Junos XML protocol client application can request information about the current status of a device running Junos OS or a device running Junos OS Evolved. To request operational information, a client application emits an <rpc> element enclosing the specific Junos XML API request tag element that returns the desired information.

Table 1 provides examples of request tags, which request the same information as the equivalent CLI command.

Table 1: Examples of Request Tags and Equivalent CLI Command
Request Tag CLI Command
<get-interface-information> show interfaces
<get-chassis-inventory> show chassis hardware
<get-system-inventory> show software information

You can determine the appropriate Junos XML request tag using multiple methods, including:

For example, the following command displays the request tag corresponding to the show interfaces command:

To execute an RPC, the client application encloses a request tag in an <rpc> element. The syntax depends on whether the request requires any additional command options.

The client application can specify the format of the information returned by the Junos XML protocol server. By setting the optional format attribute in the opening operational request tag, a client application can request the response in XML (the default), formatted ASCII text, or JavaScript Object Notation (JSON).

Note:

When displaying operational or configuration data that contains characters outside the 7-bit ASCII character set, the Junos device escapes and encodes these character using the equivalent UTF-8 decimal character reference. For more information see How Character Encoding Works on Juniper Networks Devices.

The Junos XML protocol server returns its reply in an <rpc-reply> element. The enclosed data is determined by the requested format.

If the client application requests XML output, the Junos XML protocol server encloses its response in the specific response tag element that corresponds to the request tag element.

For example, if the client application sends the <get-interface-information> RPC, the server returns the <interface-information> response tag.

For XML format, the opening tag for each operational response includes the xmlns attribute. The attribute defines the XML namespace for the enclosed tag elements that do not have a namespace prefix (such as junos:). The namespace indicates which Junos XML document type definition (DTD) defines the set of tag elements in the response.

The Junos XML API defines separate DTDs for operational responses from different software modules. For instance, the DTD for interface information is called junos-interface.dtd and the DTD for chassis information is called junos-chassis.dtd. The division into separate DTDs and XML namespaces means that a tag element with the same name can have distinct functions depending on which DTD it is defined in.

The namespace is a URL of the following form:

where:

  • release-code is the standard string that represents the Junos OS release that is running on the Junos XML protocol server device.

  • category specifies the DTD.

If the client application requests formatted ASCII text, the Junos XML protocol server encloses its response in an <output> element.

If the client application requests JSON format, the Junos XML protocol server encloses the JSON data in the <rpc-reply> tag element.