Managing Master Data with webMethods OneData : Developing for webMethods OneData : REST Web Services : GET and POST Services : GET Service Response Data
GET Service Response Data
The REST web service returns data in XML or JSON format depending on the Accept and Content-type header parameters you use. For details, see HTTP Request Header Parameters for GET and POST .
The service transforms data, as needed, so that it adheres to the XML structure, including making the following transformations:
*Escapes all special characters in the response data.
*Replaces spaces in object names and column captions with an underscore (_) character.
The GET REST service returns the XML Element Name property instead of the column name when the XML element name is defined in the column definition or foreign key constraint definition.
You can control whether OneData wraps rows in a <datarow> tag in the response , using the request parameter, baseVersion. Set baseVersion to true to generate XML output without datarows. By default, baseVersion is set to false, which returns the response data wrapped within datarows. Refer to the following XML examples of XML records wrapped within datarows.
The following code sample provides an example of XML output from the EMPLOYEE data object with datarows. In this example, EMPLOYEE is the physical object name, The remaining attributes use the XML element name. Each record is wrapped within a datarow tag.
<?xml version="1.0"?>
<EMPLOYEE>
<datarow>
<EMPLOYEE_ID>2012</EMPLOYEE_ID>
<EMPLOYEE_NAME>John Doe</EMPLOYEE_NAME>
<EMPLOYEE_DOB>1984-12-31 00:00:00.000000000</EMPLOYEE_DOB>
<EMPLOYEE_ADDRESS>H12,Brian Ave,California</EMPLOYEE_ADDRESS>
</datarow>
</EMPLOYEE>
In the next XML output sample, STATE-CITY is a conceptual object. The State and City records are wrapped within datarows.
<?xml version="1.0"?>
<STATE>
<datarow>
<ID>6</ID>
<NAME>New Jersey</NAME>
<CITY>
<datarow>
<ID>245</ID>
<NAME>Hackensack</NAME>
<POPULATION>50667</POPULATION>
</datarow>
<datarow>
<ID>453</ID>
<NAME>Cedar Falls</NAME>
<POPULATION>27083</POPULATION>
</datarow>
</CITY>
</datarow>
</STATE>
Retrieving Columns from a Foreign Key Relationship
When you are working with related tables, you can retrieve the related columns. The State object contains a foreign key relationship to the Country object through the CNTRY_ID (where CNTRY_ID is the primary key, ID, in the Country object). In the Country object, the NAME column is the description corresponding to the ID. The XML element name for the NAME column in the Country object is COUNTRY_NAME. The following table summarizes this information.
Object Name
Column Name
XML Element Name for the Column
State
ID
STATE_ID
NAME
STATE_ID
CNTRY_ID
COUNTRY_ID
Country
ID (Primary Key)
COUNTRY_ID
NAME
COUNTRY_NAME
You can also define an XML element name in the foreign key constraint. Therefore the XML element name for the foreign key constraint to the NAME column in the Country object could be Country_XML_Name.
Retrieving the State Object Using a RESTful Service
The following output is returned when a REST service retrieves the State object. Note that the XML element name used for the NAME column of the Country object is the XML element name defined in the foreign key constraint.
<?xml version="1.0" encoding="utf-8" ?>
<State>
<datarow>
<STATE_ID>3001</STATE_ID>
<STATE_NAME>State1</STATE_NAME>
<COUNTRY_XML_NAME>Country1</COUNTRY_XML_NAME>
</datarow>
<datarow>
<STATE_ID>5001</STATE_ID>
<STATE_NAME>State2</STATE_NAME>
<COUNTRY_XML_NAME>Country2</COUNTRY_XML_NAME>
</datarow>
</State>
In the next example of the REST service output, the related description column is the ID column in the Country object. In this case, the XML element name is the one defined for the ID in the Country object (Country.ID), not the XML element name of the foreign key constraint.
<?xml version="1.0" encoding="utf-8" ?>
<State>
<datarow>
<STATE_ID>3001</STATE_ID>
<STATE_NAME>State1</STATE_NAME>
<COUNTRY_ID>Country1</COUNTRY_ID>
</datarow>
<datarow>
<STATE_ID>5001</STATE_ID>
<STATE_NAME>State2</STATE_NAME>
<COUNTRY_ID>Country2</COUNTRY_ID>
</datarow>
</State>
Copyright © 2011-2017 Software AG, Darmstadt, Germany.

Product LogoContact Support   |   Community   |   Feedback