[CONTROLLER-1335] RPC Invocation via XML POST fails while equivalent JSON succeeds Created: 23/May/15  Updated: 25/Jul/23  Resolved: 25/May/15

Status: Resolved
Project: controller
Component/s: restconf
Affects Version/s: None
Fix Version/s: None

Type: Bug
Reporter: Ryan Goulding Assignee: Unassigned
Resolution: Cannot Reproduce Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Operating System: All
Platform: All


External issue ID: 3351

 Description   

Using toaster RPC as an example, POST XML to the REST endpoint fails while the equivalent POST using JSON succeeds.

XML input:
Endpoint: http://localhost:8181/restconf/operations/toaster:make-toast
Content-Type: application/xml
Body:
<input>
<toasterDoneness>1</toasterDoneness>
<toasterToastType>wheat-bread</toasterToastType>
<foo>fooValue</foo>
</input>

Status: 400 Bad Request
{"errors":{"error":[

{"error-type":"protocol","error-tag":"malformed-message","error-message":"Error parsing input: Unknown child(ren) node(s) detected, identified by: toasterDoneness, in: container input"}

]}}

When I try using JSON:
Endpoint: http://localhost:8181/restconf/operations/toaster:make-toast
Content-Type: application/xml
Body:
{
"input" :

{ "toaster:toasterDoneness" : "1", "toaster:toasterToastType" : "wheat-bread", "toaster:foo" : "fooValue" }

}
Status: 200 OK



 Comments   
Comment by Tony Tkacik [ 24/May/15 ]

Seems as mistake in toaster tutorial.

<input>
<toasterDoneness>1</toasterDoneness>
<toasterToastType>wheat-bread</toasterToastType>
<foo>fooValue</foo>
</input>

Input element needs to define namespace of toaster module, e.g.

<input xmlns="http://netconfcentral.org/ns/toaster" >
...
</input>.

Actually RPC code in Hydrogen and Helium failed to validate namespaces
and accepted input without them which was bug.

This got fixed in Lithium.

Comment by Ryan Goulding [ 24/May/15 ]

Thanks, Tony; I just verified this using stable/lithium.

I have updated the documentation https://wiki.opendaylight.org/view/OpenDaylight_Controller:MD-SAL:Toaster_Step-By-Step#Invoke_make-toast_via_RestConf to ensure transparency.

Are there existing unit or integration tests that verify restconf RPC behavior using HTTP?

Comment by Tony Tkacik [ 25/May/15 ]

Codecs are used from yangtools (instead of custom writen as in Hydrogen and partly in Helium) - these are XML codec from yang-data-impl and JSON codec from yang-data-codec-gson - unit test for codecs are also in these artefacts.

There are several CSIT tests which uses conrete models to test functionality using restconf.

Generated at Wed Feb 07 19:55:17 UTC 2024 using Jira 8.20.10#820010-sha1:ace47f9899e9ee25d7157d59aa17ab06aee30d3d.