Component: Web Service Call

 Show all Hide all

To use meta data mode system setting 'WebServiceEnabled' must be set. And services configured in the Web services menu group.

A dynamic web-service call to custom URL. Uses proxy settings defined in application variables PROXY and PROXYBYPASSLOCAL to make the request.

Component mode: Meta data

Supported modes: Meta data | Legacy

Component settings

Request timeout
Timeout in seconds for each web service request.

SQL

SQL Call: Get requests (mandatory)

Supports custom errors: No
May modify database: Yes

Parameters:

@Action mandatory string
Will be set to "GetRequests" when component asks for requests.

Resultset: Batch

Repeat mode: repeated zero or one time
Row count: zero or more rows

Columns:

BatchId optional string
BatchId of this set of requests, will be sent back to procedure for all calls.

Resultset: Requests

Repeat mode: repeated exactly once
Row count: zero or more rows

Columns:

RequestId mandatory string
Id of the request.
MethodName mandatory string
Name of the method to be called, must have a matching method in the webservice meta data.
Username optional string
Username when web service is using dynamic credentials.
Password optional string
Password when web service is using dynamic credentials.

SQL Call: Get data (mandatory)

Get the data to send to the receiver.
Supports custom errors: No
May modify database: No

Parameters:

@Action mandatory string
Will be set to "GetData" when component asks for request data.
@BatchId optional string
Only if batchid was created in the get requests call.
@RequestId mandatory string
Id of the request to be made.

Resultset: Data

Dataset generating the request data.
Repeat mode: repeated zero or more times
Row count: zero or more rows

Columns:

<Primarykey_Column> optional int
First column in table is used to identify resultset. Corresponding field must exist in web service meta data.
<Foreignkey_Column> optional int
Used to connect table to the <Primarykey_Column> of other resultsets.
<xxx> optional string
Any other column that should be a field in the request. Corresponding field must exist in web service meta data.

SQL Call: Store response (mandatory)

Prior to this call data will be stored in the staging tables.
Supports custom errors: No
May modify database: Yes

Parameters:

@<Primarykey_Column> optional int
If only one entity was returned in the root this parameter will be used.
@Action mandatory string
Will be set to "StoreResponse" when component call is successful.
@BatchId optional string
Only if batchid was created in the get requests call.
@RequestId mandatory string
Id of the request to be made

Resultset: #IdValues

Entities with a X to many relation in the root request entity will get a temporary table with id-values for all rows created in this call. If the root request entity uses a temporary table as staging table this table will not be created as all values exists in the root request entity temporary table.
Repeat mode: repeated zero or one time
Row count: zero or more rows

Columns:

Id mandatory bigint
Value of the primary key values.

SQL Call: Store error (mandatory)

Supports custom errors: No
May modify database: Yes

Parameters:

@Action mandatory string
Will be set to "StoreError" when component have failed.
@BatchId optional string
Only if batchid was created in the get requests call.
@ErrorMessage mandatory string
Error message of the failed call.
@RequestId mandatory string
Id of the request that failed.
@RequestXml mandatory string
@ResponseXml mandatory string
Response of the failed call.

SQL Call: Finished (mandatory)

Supports custom errors: No
May modify database: No

Parameters:

@Action mandatory string
Will be set to "Finished" when component have finished.
@BatchId optional string
Only if batchid was created in the get requests call.

Resultset: Forwarding definitions

Repeat mode:
Row count:

Columns:

<querystring_variable> optional string
Any column with no other specific meaning will pe passed along on the querystring to the menuitem you are forwarding to.
admin_cancelcidstepsback optional int
Number of steps in the page history to jump back if the user clicks OK in an ADMIN_MESSAGE dialog or Cancel in an ADMIN_FORCE dialog (the default being none). This value overrides cancelcidstepsback specified in the query string.
admin_cancelmenuitemid optional int
Id of the menuitem to execute if the user clicks OK in an ADMIN_MESSAGE dialog or Cancel in an ADMIN_FORCE dialog (the default being none). This value overrides cancelmenuitemid specified in the query string.
admin_cidstepsback optional int
Number of steps in the page history to jump back after execution (the default being one step back). This value overrides any destination specified by the query string.
admin_force optional string
Prompts the user with the specified text and the user may answer OK or cancel. If the user chooses OK the sql call will be rerun with the parameter @force set to 1.
admin_forward optional string
Displays a user friendly message and then forwards to the next menu item.
admin_forwardmenugroupid optional int
Id of the menu group to show after execution (instead of former menu item). This value overrides any destination specified by the query string.
admin_forwardmenuitemid optional int
Id of the menuitem to execute after execution (instead of former menu item). This value overrides any destination specified by the query string.
admin_message optional string
Displays a user friendly message to the user.
admin_pastehtmlfrompopup optional string
Pastes HTML. See admin_setfieldvaluefrompopup
admin_setfieldvaluefrompopup optional string
Sets the value of field specified in the menuitempopup call. Only select this column if menuitem is opened in popup.
admin_closepopup optional bit
If this column is anything but NULL the popup will be closed. Only select this column if the menuitem is opened in popup.
The default behavior is to step back inside the popup window and close it if there is nothing to step back to.
Cache optional string
Cache key to be cleared. Supports wildcards.
CacheUserId optional string
Either a user id or '%'.

Clears all caches (e.g. access permissions) related to the specified user id.

Use '%' to clear caches for all users.
cancelbuttontext optional string
Changes the text of the Cancel button when used with ADMIN_Force.
okbuttontext optional string
Changes the text of the OK button when used with ADMIN_Message, ADMIN_Force, or ADMIN_Forward.

SQL Call: Get url data

The call is only made if there is a UrlSuffix set in the meta data.
Supports custom errors: No
May modify database: No

Parameters:

@Action mandatory string
Will be set to "GetUrlData" when component asks for requests.
@BatchId optional string
Only if batchid was created in the get requests call.
@RequestId mandatory string
Id of the request to be made.

Resultset: Get url data

Dataset generating the url data for REST services.
Repeat mode:
Row count:

Columns:

<xxx> optional string
Columnname will replace corresponding {xxx} in url-suffix from web service meta data.

SQL Call: Get http headers

The call is only made if there are headers in the meta data.
Supports custom errors: No
May modify database: No

Parameters:

@Action mandatory string
Will be set to "GetHeaderData" when component asks for requests.
@BatchId optional string
Only if batchid was created in the get requests call.
@RequestId mandatory string
Id of the request to be made.

Resultset: Http headers

Repeat mode: repeated exactly once
Row count: exactly one row

Columns:

<ColumnName> mandatory string
Any column name must be any header that exists in the web service method meta data.

SQL Call: Validate parameters

Allows you to validate the parameters supplied by the user before any other SQL is run in the component. This call is only made if the component has visible parameters, the SQL is a stored procedure, and 'Validate parameters' is checked.
Supports custom errors: No
May modify database: No

Parameters:

@force optional bit
@validateparams mandatory bit
This parameter is set to 1 by Softadmin® when this call is made.

Custom access control and logging

SQL Call: Custom access control and logging

Use this call to restrict which entries a user is allowed to view and edit, and to log which entries a user views.

Access to a menu item is normally controlled through functions and roles alone but some entities need more fine grained control. For example, a user may have access to the View Member menu item for normal members but not for members with a protected identity.

The menu items a user visits are always logged (in ADMINLogMenuItem) but for sensitive data you may need to log exactly what entries are viewed. Do the logging in this call as the common ways of viewing data (grid and InfoSQL) are not allowed to modify the database.

If you bind a scalar function instead of a stored procedure to this call then its name must end with '_GrantAccess'.
Supports custom errors: No
May modify database: Yes

Resultset: Access permissions

Return whether the user is allowed to visit the menu item with the current parameters.
Repeat mode: repeated exactly once
Row count: exactly one row

Columns:

GrantAccess mandatory bit
1 if the user is allowed to view the menu item, 0 if the user should not be allowed to view the menu item.

If 0 then an error will be logged as the user should not have been able to reach the menu item with the given parameters in the first place.

Examples

Example requests

CREATE PROCEDURE [dbo].[WebServiceCall]
	@Action nvarchar(max) = NULL,
	@RequestId int = NULL,
	@BatchId nvarchar(max) = NULL,

	@ResponseEntityStagingId int = NULL,
	@RequestXml nvarchar(max) = NULL,
	@ResponseXml nvarchar(max) = NULL,
	@ErrorMessage nvarchar(max) = NULL
AS
BEGIN
	IF @Action = 'GetRequests'
	BEGIN
		SELECT
			NEWID() AS BatchId

		SELECT
			'MyMethod' AS MethodName,
			CallQueueId AS RequestId
		FROM
			dbo.CallQueue;

		RETURN;
	END;

	IF @Action = 'GetUrlData'
	BEGIN
		SELECT
			DataValue AS UrlParameter
		FROM
			dbo.Data;

		RETURN;
	END;

	IF @Action = 'GetData'
	BEGIN
		SELECT
			DataId,
			DataValue
		FROM
			dbo.Data;

		SELECT
			DataRowId,
			DataId,
			DataRowValue
		FROM
			dbo.DataRow;

		RETURN;
	END;

	IF @Action = 'StoreError'
	BEGIN
		-- Depending on your situation

        SELECT
            @ErrorMessage = CONCAT('Error in procedure: ' + OBJECT_NAME(@@PROCID), @ErrorMessage);
		-- INSERT INTO LogTable (and possibly display error in Finished call)
		EXEC SoftadminApi.Log_LogError
        	    @LogMessage = @ErrorMessage
		RETURN;
	END;

	IF @Action = 'StoreResponse'
	BEGIN
		DECLARE
			@ResponseValue int;

		SELECT
			@ResponseValue = ResponseValue
		FROM
			ResponseEntityStaging
		WHERE
			ResponseEntityStagingId = @ResponseEntityStagingId;

		EXEC dbo.InsertResponse
			@ResponseValue = @ResponseValue;

		RETURN;
	END;

	IF @Action = 'Finished'
	BEGIN
		SELECT
			1 AS ADMIN_ForwardMenuitemId,
			@BatchId AS BatchId;

		RETURN;
	END;
END;

Minimal example

CREATE PROCEDURE [dbo].[WebServiceCall]
    @Action nvarchar(max) = NULL,
    @RequestId int = NULL,
    @BatchId nvarchar(max) = NULL,
    @RequestXml nvarchar(max) = NULL,
    @ResponseXml nvarchar(max) = NULL,
    @ErrorMessage nvarchar(max) = NULL
AS
BEGIN
    IF @Action = 'GetRequests'
    BEGIN
        SELECT
            'MyMethod' AS MethodName,
            1 AS RequestId;
        RETURN;
    END;

    IF @Action = 'GetUrlData'
    BEGIN
        RETURN;
    END;

    IF @Action = 'GetData'
    BEGIN
        RETURN;
    END;

    IF @Action = 'StoreError'
    BEGIN
        SELECT
            @ErrorMessage = CONCAT('Error in procedure: ' + OBJECT_NAME(@@PROCID), @ErrorMessage);
        EXEC SoftadminApi.Log_LogError
                @LogMessage = @ErrorMessage;

        RETURN;
    END;

    IF @Action = 'StoreResponse'
    BEGIN
        RETURN;
    END;

    IF @Action = 'Finished'
    BEGIN
        RETURN;
    END;
END;