When performing an HTTP POST to a web script, the posted request body often contains content that needs processing by the web script. To allow access to the request body, the Web Script Framework provides a special root object named requestbody that represents the content of the request. The requestbody is a ScriptContent object allowing access to the request content either as a string or as a content stream.
This task demonstrates request processing by creating a web script, which simply responds with the content of the HTTP request.
-
Log in to Alfresco Share:
-
Create a web script description document for your request body sample:
-
Create a controller script for your request body sample:
-
Create an HTML response template for your request body sample:
-
Register the web scripts with Content Services:
-
Test this web script with cURL by typing the following in your command line:
Often the content posted in a request is structured using data formats such as XML or JSON, which the web script has to parse. Parser code is generally painful to develop, so the Web Script Framework provides a mechanism known as a Format Reader that parses a request of a given MIME type into an object that represents the request content. The object is then supplied to the controller script, which can interrogate the object to extract request content.