namespace \webfiori\http
abstract class AbstractWebService
Class Attributes Summary
Class Methods Summary
Class Attributes Details
- GET
- HEAD
- POST
- PUT
- DELETE
- TRACE
- OPTIONS
- PATCH
- CONNECT
Class Methods Details
Creates new instance of the class. The developer can supply an optional service name. A valid service name must follow the following rules:
- It can contain the letters [A-Z] and [a-z].
- It can contain the numbers [0-9].
- It can have the character '-' and the character '_'.
Parameters:
- string $name The name of the web service.
Parameters:
- RequestParameter|array $param The parameter that will be added. It can be an object of type 'RequestParameter' or an associative array of options. The array can have the following indices:
- name: The name of the parameter. It must be provided.
- type: The datatype of the parameter. If not provided, 'string' is used.
- optional: A boolean. If set to true, it means the parameter is optional. If not provided, 'false' is used.
- min: Minimum value of the parameter. Applicable only for numeric types.
- max: Maximum value of the parameter. Applicable only for numeric types.
- allow-empty: A boolean. If the type of the parameter is string or string-like type and this is set to true, then empty strings will be allowed. If not provided, 'false' is used.
- custom-filter: A PHP function that can be used to filter the parameter even further
- default: An optional default value to use if the parameter is not provided and is optional.
- description: The description of the attribute.
Parameters:
- array $params An associative or indexed array. If the array is indexed, each index should hold an object of type 'RequestParameter'. If it is associative, then the key will represent the name of the web service and the value of the key should be a sub-associative array that holds parameter options.
Parameters:
- string $paramName The name of request parameter as specified when it was added to the service.
Parameters:
- string $name The name of the parameter.
Parameters:
- string $paramName The name of the parameter (case sensitive).
Parameters:
- string $method The request method (e.g. 'get', 'post', 'options' ...). It can be in upper case or lower case.
Parameters:
Sends a JSON response to the client. The basic format of the message will be as follows:
{
"message":"Action is not set.",
"type":"error"
"http-code":404
"more-info":EXTRA_INFO
}
Parameters:
- string $message The message to send back.
- string $type A string that tells the client what is the type of the message. The developer can specify his own message types such as 'debug', 'info' or any string. If it is empty string, it will be not included in response payload.
- int $code Response code (such as 404 or 200). Default is 200.
- mixed $otherInfo Any other data to send back it can be a simple string, an object... . If null is given, the parameter 'more-info' will be not included in response. Default is empty string. Default is null.
Parameters:
- boolean $bool True to make authorization step required. False to skip the authorization step.
Parameters:
- WebServicesManager|null $manager The manager at which the service will be associated with. If null is given, the association will be removed if the service was associated with a manager.
Returns a Json object that represents the service. The generated JSON string from the returned Json object will have the following format:
{
"name":"",
"since":"",
"description":"",
"request-methods":[],
"parameters":[],
"responses":[]
}