# Why does this action encoder function work?

**URL:** <https://dmap-community.ductus.global/t/why-does-this-action-encoder-function-work/2468>\
**Category:** NETCONF\
**Created:** [May 14, 2019, 2:19am UTC](https://dmap-community.ductus.global/t/why-does-this-action-encoder-function-work/2468 "2019-05-14T02:19:35Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![buddha87](https://avatars.discourse-cdn.com/v4/letter/b/5f8ce5/32.png) [@buddha87](https://dmap-community.ductus.global/u/buddha87)\
**Post date:** [May 14, 2019, 2:19am UTC](https://dmap-community.ductus.global/t/why-does-this-action-encoder-function-work/2468/1 "2019-05-14T02:19:35Z")

</div>

I am working in a project which I try to use tailf. JNC package. I try to create action request and I can see JNC has the API : NetconfSession.action().  
When I dig into the function and I can see there is an encoding function : encode\_action().

> <https://github.com/tail-f-systems/JNC/blob/master/jnc/src/com/tailf/jnc/NetconfSession.java#L2542>

```
void encode_action(Transport out, Element data) throws JNCException {
        final String prefix = Element.defaultPrefixes.nsToPrefix(Capabilities.NS_ACTIONS);
        final String act = mk_prefix_colon(prefix);
        final String xmlnsAttr = mk_xmlns_attr(prefix, Capabilities.NS_ACTIONS);
        encode_rpc_begin(out);
        out.println("<" + act + "action " + xmlnsAttr + ">");
        out.print("<" + act + "data>");
        data.encode(out);
        out.println("</" + act + "data>");
        out.println("</" + act + "action>");
        encode_rpc_end(out);
    }

```

But the request xml tag inside this function doesn’t comply with the netconf action XML Encoding Rule  
[https://tools.ietf.org/html/rfc7950#section-7.15.3](https://tools.ietf.org/html/rfc7950#section-7.15.3)

But I try and it actually work with confd 6.6.1. Any idea why ? Is there any other version of XML encoding rule for “action” ?

---

<div class="post-metadata">

**Author:** ![buddha87](https://avatars.discourse-cdn.com/v4/letter/b/5f8ce5/32.png) [@buddha87](https://dmap-community.ductus.global/u/buddha87)\
**Post date:** [May 15, 2019, 2:43am UTC](https://dmap-community.ductus.global/t/why-does-this-action-encoder-function-work/2468/2 "2019-05-15T02:43:09Z")

</div>

Any idea how the action encoder can work?

---

<div class="post-metadata">

**Author:** ![mvf](https://yyz2.discourse-cdn.com/flex010/user_avatar/dmap-community.ductus.global/mvf/32/182_2.png) [@mvf](https://dmap-community.ductus.global/u/mvf)\
**Post date:** [May 15, 2019, 8:54am UTC](https://dmap-community.ductus.global/t/why-does-this-action-encoder-function-work/2468/3 "2019-05-15T08:54:05Z")

</div>

This is the encoding required by `tailf:action` custom extension. The old standard YANG 1.0 (RFC 6020) defined only `rpc` for custom RPCs, and they could be used only on the top level; ConfD introduced the extension to allow custom RPCs to be defined anywhere in the data model. The requirements of `tailf:action` and `action` are almost identical, one notable difference is the XML encoding, but ConfD obviously accepts the standard as well as the custom variant.

---

<div class="post-metadata">

**Author:** ![buddha87](https://avatars.discourse-cdn.com/v4/letter/b/5f8ce5/32.png) [@buddha87](https://dmap-community.ductus.global/u/buddha87)\
**Post date:** [May 15, 2019, 5:51pm UTC](https://dmap-community.ductus.global/t/why-does-this-action-encoder-function-work/2468/4 "2019-05-15T17:51:43Z")

</div>

Thank you for explanation. OK, this explain why this encoder also works for “action”.  
Since this a custom RPCs in Confd extension, is that possible later version Confd won’t accept the custom variant any more ?

---

<div class="post-metadata">

**Author:** ![mvf](https://yyz2.discourse-cdn.com/flex010/user_avatar/dmap-community.ductus.global/mvf/32/182_2.png) [@mvf](https://dmap-community.ductus.global/u/mvf)\
**Post date:** [May 16, 2019, 7:47am UTC](https://dmap-community.ductus.global/t/why-does-this-action-encoder-function-work/2468/5 "2019-05-16T07:47:28Z")

</div>

The custom `tailf:action` is going to stay for long and the corresponding encoding too, that’s for sure. The question is if developers do not decide to require that the encoding matches the actual data model, so if you are using 1.1 models with the standard `action`, you might lose ability to invoke actions with JNC (or maybe not, I really do not know). On the other hand: JNC is open source, and as far as I can tell, it should not be difficult to add a method `NetconfSession.rfc_action` or something along these lines. I’m pretty sure such contribution would be more than welcome by the maintainer.
