M/DB:X Response Structure

M/DB:X responses take the form of either XML documents or JSON strings. XML is the default output format, but by simply adding the name/value pair OutputFormat=JSON to an M/DB:X HTTP request, the response will be automatically formatted as a corresponding JSON object string.

XML responses are returned as Content-type: text/xml. JSON responses are returned as Content-type: application/json.

There are two types of responses possible from M/DB:X:

Error Responses

All error responses follow the pattern of the example below:

XML format:

<?xml version='1.0'?>
            Non-existent or Invalid Document Name

JSON format:

{ErrorCode:"InvalidDocumentName",ErrorMessage:"Non-existent or Invalid DocumentName"}

The two key pieces of information are the error code and message.

Correct Responses

The actual content from M/DB:X Actions varies from Action to Action, but the overall structure is typified by the following example, typical outout from the ListDOMs action:

XML Format

<?xml version='1.0'?>
<ListDOMsResponse xmlns="http://mdbx.mgateway.com/doc/2009-06-05/">

Almost all of the XML responses from M/DB:X Actions have an outer element named ActionResponse with a namespace of http://mdbx.mgateway.com/doc/2009-06-05/, with the response content further wrappered by an element named ActionResult. Those familiar with SimpleDB will recognise this pattern.

The main exception to this M/DB:X XML formatting pattern is the outputDOM Action which outputs the specified XML document without any added XML container or wrapper.

JSON format


In this case, the response is a JSON array of objects. In other APIs, a JSON object is returned, eg:


If you use the OutputJSON Action, M/DB:X will automatically convert the specified XML DOM into a corresponding JSON object, eg:

{rob:{span:{div:null,jsonTest:{x1:"testing",param2:"hello",#text:"This is an example"},
jsonTest2:[{x1:"testing",#text:"This is an example"},{x1:"testing",#text:"This is an example"},
{x1:"testing",#text:"This is an example"},{x1:"testing",#text:"This is an example"}],
myNewTag2:{a:"helloxxx",b:"234555",id:"rob1",#text:"world"},robnew1:{span:"hello world!"},span:null}}}

Note that M/DB:X can convert an XML DOM to JSON format irrespective of how the DOM was created: it is not restricted to DOMs that were created from JSON input.