Passing an Object Parameter

Only one object parameter can be defined for a REST services method, and it can appear in any position in the signature except after a ParamListType parameter. If the method signature includes an object parameter, the information for the object must be provided in XML or JSON format. The method can contain references to other child objects that were also passed in the XML or JSON.

In the following POST request, an object is passed in XML format.

POST http://localhost/jade/jadehttp.dll/customer?RestApp
XML-Formatted Object

An XML‑formatted object is identified by its header.

<?xml version="1.0" encoding="UTF-8"?>

The XML is parsed to create a transient instance of the specified type, which is passed to the REST service method. When the method has completed execution, the transient object and any child objects that were created are deleted.

Classes or properties referenced in the XML that do not exist in the schema are ignored. For a property that does exist, an exception is raised if the passed value in the XML is of the wrong type.

The following XML creates a Customer object.

<?xml version="1.0" encoding="UTF-8"?>
<Customer>
    <name>Clark Kent</name>
    <address>Smallville</address>
</Customer>

The XML can indicate that the passed object is null. If the base object is not null, the object must be of the type required by the parameter in the JadeRestService subclass. If it is not the required type, an exception is raised.

If an XML header is not found, the text is searched for the first opening brace character ({) for a non-Collection parameter type, or for the first opening brace ({) character or bracket ([) character for a Collection type. If such a character is found, it is assumed that the object is in JSON.

JSON-Formatted Object

In the following POST request, an object is passed in JSON.

POST http://localhost/jade/jadehttp.dll/customer?RestApp

The following JSON creates a Customer object.

{"name":"Clark Kent","address":"Smallville"}

The JSON is parsed and a transient instance of the parameter type is created and populated. As the class name is not specified in JSON, if you pass the wrong object, the entire content is ignored unless both object types have identical property names.

Classes or properties referenced in the JSON that do not exist in the schema are ignored. For a property that does exist, an exception is raised if the passed value in the JSON is of the wrong type.

When the method has completed execution, the transient object is deleted.

Null Object

You can pass a null object to a REST request by adding the string null to the request body.