Nxs service - xkp/Doc GitHub Wiki

##Overview

Web services will serve information usually not HTML formatted. The client pages will use such information in the way they see fit.

##Usage Excess provide a simple way to create services:

1- Declare the service in your application's definition file (xml):

<service id="<Your service name>" post="<true|false>" upload_dir="<Where uploaded files will go>"/>
HTTP Method

The http method is derived from the post parameter, which defaults to false meaning GET will be used. This same principle applies to pages.

Parameter resolution

Depending on the chosen http method the parameters will be resolved using the names provided in step 2. This same principle applies to pages.

Uploaded files

The exception to the above rule are uploaded files, which will only be available on post requests. To access such files you must access the post property, which at the moment follows the interface of the underlying implementation library (formidable)

var filename = post.files[0].name;

This same principle applies to pages.

2- Implement your service as a traditional xs method in your application code (xs):

method <Your service name>( <Your service parameters> )
{
    return <Your service results>;
}
Response resolution

The header and data of xs web services will be derived from the return type of its implementing method. This feature is still fluid in the current implementation and will recognize value data and objects, returning a JSON string to the client.

⚠️ **GitHub.com Fallback** ⚠️