Class wwRestProcess

The wwRestService class is a specialized wwProcess class that can be used for REST services. This class simplifies generating 'service' output in JSON and XML format and parsing input parameters from JSON into plain parameters.

A Rest process has these features:

  • Simple parameter input and output
    REST methods are implemented receive parameters that are parsed from JSON, and return values as plain FoxPro values, objects, collections, arrays or cursors. Typically you don't use Request and Response objects much, but rely on API parameters to pass in data and simply return values/objects.

  • JSON parsing and JSON and XML Output
    For each request a single value/object can be passed as a JSON object from the client and get mapped to the endpoint input parameter. Any FoxPro return values from the endpoint method are by default turned to JSON and optionally to XML.

  • Use Accept HTTP Header from Client to specify JSON or XML
    Use the Accept: HTTP header to specify what format to return (Accept: application/json, Accept: text/xml). Note that JavaScript libraries like jQuery and Angular automatically POST data as application/json so you get JSON input typically.

  • Continue to use the Request Object to get other Request info
    You can still use Request.QueryString() and Request.Form() to parse non-JSON input data from URLs and it's also possible to return Response.Write() results by setting Service.IsRawResponse = .T. which doesn't serialize the result or tries to set the output content type.

The wwRestProcess provides a simple mechanism for creating REST APIs by abstracting away most of the logistics of the Web Connection framework and leaving you to implement simple methods with input parameters and result values that are implemented like any other FoxPro business logic method.


Services methods expose the following PRIVATE variables that let you control lower level access to the server:

  • JsonService
    The wwJsonService class that controls the JSON input and output parsing. This is useful to override behavior of the service, such as telling it to not generate any output using the IsRawResponse property which you can use if you want to use the Response object to return your own output. Use this to return non-data results such as images, documents or occasional HTML from a service. When used the return value of the method is ignored.

  • Serializer An instance of the wwJsonSerializer which allows you to override behavior of the serializer. For example, you can override things like the PropertyNameOverrides property to generate 'proper' field names rather than all lowercase.

  • Request, Response, Server, Process, Session etc.
    Of course all the other, normally exposed objects inside of process classes are also in scope so you can access any Request object methods like QueryString or ServerVariables() to retrieve input.

Class Members




Hook method that allows you to into every REST service call before the call is made.

Use this method to set global JsonService or JsonSerializer settings that are applied on every request.


Hook class that is called to create an instance of wwJsonService which is responsible for making the actual method call.



Creates an error response formatted into the proper output format depending on the Accept header of the request. Defaults to JSON, if no Accept header is provided.

o.ErrorResponse(lcMessage, lcStatus)


Instance of the wwJsonService object that's handling the request. Also available as JsonService inside of service methods (as well as Serializer for the wwJsonSerializer instance)

See also:

Using wwRestProcess Class | How wwRestService works

© West Wind Technologies, 1996-2021 • Updated: 06/02/17
Comment or report problem with topic