Creates web service endpoints. This is not a component and therefore menu items are not created for it.
Web services are administered from the Web service publishing raw mode (beta) menu item in the Web services subgroup in the Admin menu group.
The .NET Core hosting bundle for version 8.x needs to be installed on the web server. You can find the currently installed version in Admin/Softadmin® system information.
The WS folder must be converted to an application in IIS Manager. The application must use an app-pool running in 64 bit mode ("Enable 32-bit applications"=false).
WebServicePublishingUrl must be set to the URL of the the IIS application created for the "WS" folder.
By default the same connection string is used as for Softadmin. But this can be customized.
Two connection strings named: "Softadmin" and "SoftadminWebServices" may be used to use a different database user for web service calls. These may be added to database.config or database.json (see "Hosting from a different folder").
"Softadmin" is used for any internal calls and require the same permissions to the database as Softadmin.
"SoftadminWebServices" is used to execute calls controlled by the developer, for example the calls to the the procedure of the method, and may have limited access to a specific schema or set of procedures.
When the application is hosted in another folder than Softadmin or the developer wants to use specific connection strings for web service publishing the file database.json in the "WS"-folder may be edited. Otherwise the connection strings from database.config in the main folder are used. The format should be:
{ "ConnectionStrings": { "Softadmin": "Add connection string here", "SoftadminWebServices": "Optional. Add connection string here" } }
The web service application can be hosted as a separate application instead of a sub application of Softadmin®. In the IIS create a separate application.
Any HTTP headers supplied in the request. If the same header is set multiple times it will be concatenated into a comma-separated string.
The name of the HTTP header.
The value of the HTTP header.
The response body.
JSON to be returned as the response body.
Text to return as response body. Should be used if other encoding of content type is desired than for JSON.
Content type for the data. May not be used with the "ResponseJson" column, it always uses content type "application/json". Required when using the columns "ResponseText" or "ResponseBinary".
Encoding of the text in the "ResponseText" column. Defaults to "utf-8". May not be used with the "ResponseJson" column, it always uses encoding "utf-8".
The response HTTP status code.
The response HTTP status code.
The response HTTP headers.
The name of the HTTP header.
The value of the HTTP header.
Regular query string parameters are passed as parameters to the procedure, and use the notation {xxx} in the path. See the parameter @<QueryStringParameter> above.
The special temp table #QueryStringParameter will only exist if the path contains the special notation {xxx...}. "..." is specifying the parameter may occur more than once in the query string.
One row will be created for each occurrence of the query string value in the request. The query string ?test=1&test=2 would create 2 rows with the values 1 and 2.
The key of the query string value
The value of the query string value.
Most likely this procedure will not be used, but the error format will need to be added to the OpenAPI-specification document. Only called if "Custom error formatting procedure" is explicitly set for the procedure.
The procedure is used to format the error response body for internal errors in a different format than below.
The default error format is JSON in the following format:
{ "ErrorMessage": "<Error message content>", "ErrorCode": "<Error code>" }
Possible value | Description |
---|---|
InternalError | An internal error occured. |
InvalidQueryString | The query string is in invalid format. |
RequestBodyTooLarge | The request body size exceeds the specified max request size for the method. |
Unauthorized | The client failed authorization. |
JSON to be returned as the response body.
Text to return as response body. Should be used if other encoding of content type is desired than for JSON.
Content type for the data. May not be used with the "ResponseJson" column, it always uses content type "application/json". Required when using the columns "ResponseText" or "ResponseBinary".
Encoding of the text in the "ResponseText" column. Defaults to "utf-8". May not be used with the "ResponseJson" column, it always uses encoding "utf-8".
The response HTTP status code.
The name of the HTTP header.
The value of the HTTP header.
ALTER PROCEDURE dbo.WebService_Car_Get_Example
@ExternalGuid uniqueidentifier,
@ClientId nvarchar(max),
@RequestBodyText nvarchar(max)
AS
BEGIN
SET NOCOUNT, XACT_ABORT ON;
SELECT
(
SELECT
C.RegNr,
C.SoldDateTime,
C.Price
FROM
dbo.Car C
WHERE
C.ExternalGuid = @ExternalGuid
FOR JSON PATH, WITHOUT_ARRAY_WRAPPER
) AS ResponseJson;
END;
CREATE PROCEDURE dbo.WebService_ErrorHandling_Example
@ErrorMessage nvarchar(max),
@ErrorCode nvarchar(300),
@HttpStatusCode int,
@MethodPath varchar(300),
@RequestBodyText nvarchar(max)
AS
BEGIN
SET NOCOUNT, XACT_ABORT ON;
-- Example of changing the name of the "ErrorCode" property to "ErrorCodeInternal"
SELECT
(
SELECT
@ErrorMessage AS ErrorMessage,
@ErrorCode AS ErrorCodeInternal
FOR JSON PATH, WITHOUT_ARRAY_WRAPPER
) AS ResponseJson;
END;
Do not return huge amounts of data in a single call but rather partition the data and let the client send multiple calls. Downloading huge responses requires the connection to be held the whole duration and a lost connection may require the client to download the whole response again. This applies to both large files and large text responses.
By default the recommendation is to inherit all methods that are not changing to the new version, this way the caller can always be recommended to call the latest version of the API.