The Assembler Service provides a RESTful interface for making Assembler queries and retrieving results in either JSON or XML.
You query the Assembler Service by making a GET request to a URL that specifies the location of a content item that you wish to assemble. The URL should be of the following form:
http://[hostname:port]/[servlet-path]/[content-URI]?[query-params]
In the reference deployment of the Assembler Service, the servlet path
determines the format of the Assembler response. The deployment descriptor file
(web.xml) in the reference deployment defines two
servlets:
|
Servlet path |
Servlet description |
|---|---|
|
|
Returns the Assembler response as JSON. |
|
|
Returns the Assembler response as XML. |
The difference between the servlets is in the
ResponseWriter implementation that they use. It is also
possible to write an Assembler response writer that forwards the results to
another servlet rather than serializing them.
The
content-URI is the path to the content item to be
assembled.
The Assembler servlet request URL
http://www.example.com/json/browse is equivalent to
passing a
ContentInclude item to the Assembler
assemble() method with the URI
/pages/[site-ID]/browse and retrieving the results in
JSON format.
Query parameters in an Assembler servlet request URL are processed the
same way as in the embedded Java Assembler. For example, the URL
http://www.example.com/json/browse?N=101022 with the
reference Assembler servlet deployment returns the same results as
http://www.example.com/discover/browse?N=101022 in
the reference Java application.
If your Experience Manager implementation has multiple sites within an
application, you must use a domain or URL pattern in your Assembler servlet
request URL or pass a site ID parameter. For example, if your site uses a
domain pattern for a cameras site, your request URL could be
http://.
If your site uses a URL pattern for a cameras site, your request URL could be
cameras.discover.com/json/browsehttp://localhost:8006/json/cameras/browse where
/cameras is the URL pattern.
To pass a site ID parameter, you can use this format
http://localhost:8006/json/browse?siteId=/DiscoverCameras
for a DiscoverCameras site.
Unlike the Assembler in embedded mode, which allows assembly of any
configuration content item, all queries to the Assembler servlet are treated as
content include queries. To request content dynamically from a content folder
based on a set of trigger criteria, you can create a content slot at a location
in the sitemap that you can then specify in your Assembler request URL. In the
reference implementation, the
browse page is one example of a content item that
is addressable by URI that then references content items within a specified
folder path.
Related links
The Assembler provides response writer implementations that serialize the Assembler response to JSON or XML.
The Assembler response takes the form of a content item (that is, a map of properties). The properties are key-value pairs where the key is a string and the value may be one of the following types:
This structure makes it straightforward to serialize the response to JSON.
The XML output of the Assembler (using the default
XmlResponseWriter) is not SOAP-compliant. The default
XML format has the following characteristics:
<Item>may have either atypeattribute whose value is equivalent to the templateidthat defined the content item, or aclassattribute in the case of a strongly typed reponse model for a content item.Each
<Property>element has anameattribute whose value is the property key, and contains either a<String>,<Boolean>,<Integer>,<List>, or<Item>element whose contents represent the property value.
For convenience, the Discover Electronics reference application provides links to the JSON and XML representations of the Assembler response, which are identical to the output of the Assembler servlet. This link can be useful for debugging purposes, but it is not recommended as a primary means of querying the Assembler for JSON or XML-formatted results.

