Web Service Call

Show allHide all

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

Component modes: Meta data | Legacy

Component mode: Meta data

Component settings

Max generations
Each batch of requests recieved from the GetRequests or StoreResponse calls count as one generation. The component will crash if it reaches the given maximum number of generations allowed to prevent getting stuck in infinite loops.
Request timeout
Timeout in seconds for each web service request.

SQL

SQL Call: Get requests (mandatory)

May modify database: Yes

Parameters

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

Resultset: Batch (optional)

Table count: repeated zero or one time
Row count: exactly one row

Columns

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

Resultset: Requests

Table count: 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 web service meta data.
Username optional string
Deprecated; use the column Credentials instead. Username when the web service is using dynamic credentials.
Password optional string
Deprecated; use the column Credentials instead. Password when the web service is using dynamic credentials.
Url optional string
URL when web service is using dynamic URL.
Credentials optional string
The internal name of the credentials to use when the web service is using dynamic credentials.
ProgressTitle optional string
Displays a progress bar. See procedure SoftadminApi.Progress_SetTitle for further explaination.
ProgressText optional string
A name or other description of the current operation, for example the recipient of the web service call currently being processed.
ProgressStepsCompleted optional int
How many steps of the current operation have been completed. Omit this parameter or pass NULL to make the web service call progress indeterminate. If set then ProgressStepsTotal must also be set.
ProgressStepsTotal optional int
How many steps total are to be performed. Omit this parameter or pass NULL to make the operation's progress indeterminate. If set then ProgressStepsCompleted must also be set.

SQL Call: Get URL data

The call is only made if there is a UrlSuffix set in the meta data.

May modify database: No

Parameters

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

Resultset: Get url data

Dataset generating the url data for REST services.
Table count:
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.

May modify database: No

Parameters

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

Resultset: Http headers

Table count: 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: Get data

Get the data to send to the receiver. This is only called when the method does not use raw input. Otherwise the Get raw data call is used instead.

May modify database: No

Parameters

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

Resultset: Data (optional)

Dataset generating the request data.
Table count: 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: Get raw data

Get the data to send to the receiver. This is only called when the method uses raw requests. Otherwise the Get data call is used instead.

May modify database: No

Parameters

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

Resultset: Multipart extra info (optional)

Dataset used to change default behavior of MultipartContent requests.
Table count: repeated zero or one time
Row count: exactly one row

Columns

MultipartContentType optional string
Content-type of the main part. Must start with "multipart/". Default is "multipart/mixed".

Resultset: Headers (optional)

Dataset generating the headers for the request and it's content. Must come before the content.
Table count: repeated zero or one time
Row count: zero or more rows

Columns

PartId optional string
Used to connect headers to a specific content when using MultipartContent. Do not use this column unless you need to send MultipartContent. Set to NULL when the header should be added to the request.
HttpHeaderName mandatory string
Name of the header.
HttpHeaderValue mandatory string
Value of the header.

Resultset: Content (optional)

Dataset generating the request content.
Table count: repeated zero or one time
Row count: zero or more rows

Columns

PartId optional string
Used to connect content and headers when using MultipartContent requests. Do not use this column unless you need to send MultipartContent.
ContentType optional string
Specifies the content type.
Encoding optional string
Encoding used for the content. Can not be used together with the BinaryContent column.
TextContent optional string
Specifies the text content. Only one of TextContent and BinaryContent is allowed to have a value for each row.
BinaryContent optional binary
Specifies the binary content. Only one of TextContent and BinaryContent is allowed to have a value for each row.

SQL Call: Store response

Prior to this call data will be stored in the staging tables. This is only called when the method does not use raw output. Otherwise the Store raw response call is used instead.

May modify database: Yes

Parameters

@<Primarykey_Column> int
If only one entity was returned in the root this parameter will be used.
@Action string
Will be set to "StoreResponse" when component call is successful.
@BatchId string
Only if batchid was created in the get requests call.
@HttpStatusCode string
The HTTP status code from the response. Will only be set if the method has "Receive HTTP code" activated.
@RequestId string
Id of the request to be made

Resultset: Clear request queue (optional)

Must be sent in before the Requests resultset. If new requests are sent in, the queue will be cleared before the new requests are queued.
Table count: repeated zero or one time
Row count: exactly one row

Columns

ClearQueue mandatory bit
Set to 1 to clear the request queue.

Resultset: Requests (optional)

Additional requests to be added to the end of the call queue.
Table count: repeated zero or one time
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 web service meta data.
Username optional string
Deprecated; use the column Credentials instead. Username when the web service is using dynamic credentials.
Password optional string
Deprecated; use the column Credentials instead. Password when the web service is using dynamic credentials.
Url optional string
URL when web service is using dynamic URL.
Credentials optional string
The internal name of the credentials to use when the web service is using dynamic credentials.
ProgressTitle optional string
Displays a progress bar. See procedure SoftadminApi.Progress_SetTitle for further explaination.
ProgressText optional string
A name or other description of the current operation, for example the recipient of the web service call currently being processed.
ProgressStepsCompleted optional int
How many steps of the current operation have been completed. Omit this parameter or pass NULL to make the web service call progress indeterminate. If set then ProgressStepsTotal must also be set.
ProgressStepsTotal optional int
How many steps total are to be performed. Omit this parameter or pass NULL to make the operation's progress indeterminate. If set then ProgressStepsCompleted must also be set.

Resultset: #IdValues (optional)

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.
Table count: repeated zero or one time
Row count: zero or more rows

Columns

Id mandatory bigint
Value of the primary key values.

Resultset: #HttpHeader (optional)

Contains the custom response HTTP headers from the webservice call.
Table count: repeated zero or one time
Row count: zero or more rows

Columns

HttpHeaderName mandatory string
Contains the name of the header.
HttpHeaderValue mandatory string
Contains the value of the header.

SQL Call: Store raw response

Store the data recieved from the call. This is only called when the method uses raw responses. Otherwise the Store data call is used instead. The temporary tables #Content and #HttpHeader will be passed to the procedure.

May modify database: Yes

Parameters

@Action string
Will be set to "StoreRawResponse" when component call is successful.
@BatchId string
Only if batchid was created in the get requests call.
@HttpStatusCode string
The HTTP status code from the response.
@RequestId string
Id of the request to be made.

Resultset: Clear request queue (optional)

Must be sent in before the Requests resultset. If new requests are sent in, the queue will be cleared before the new requests are queued.
Table count: repeated zero or one time
Row count: exactly one row

Columns

ClearQueue mandatory bit
Set to 1 to clear the request queue.

Resultset: Requests (optional)

Additional requests to be added to the end of the call queue.
Table count: repeated zero or one time
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 web service meta data.
Username optional string
Deprecated; use the column Credentials instead. Username when the web service is using dynamic credentials.
Password optional string
Deprecated; use the column Credentials instead. Password when the web service is using dynamic credentials.
Url optional string
URL when web service is using dynamic URL.
Credentials optional string
The internal name of the credentials to use when the web service is using dynamic credentials.
ProgressTitle optional string
Displays a progress bar. See procedure SoftadminApi.Progress_SetTitle for further explaination.
ProgressText optional string
A name or other description of the current operation, for example the recipient of the web service call currently being processed.
ProgressStepsCompleted optional int
How many steps of the current operation have been completed. Omit this parameter or pass NULL to make the web service call progress indeterminate. If set then ProgressStepsTotal must also be set.
ProgressStepsTotal optional int
How many steps total are to be performed. Omit this parameter or pass NULL to make the operation's progress indeterminate. If set then ProgressStepsCompleted must also be set.

Resultset: #Content

Contains the raw content data returned from the call.
Table count: repeated exactly once
Row count: exactly one row

Columns

ContentType mandatory string
Content type of the response.
TextContent mandatory string
Contains the raw text content of the response.
BinaryContent mandatory binary
Contains the binary content of the response.

Resultset: #HttpHeader

Contains all headers from the response.
Table count: repeated exactly once
Row count: zero or more rows

Columns

HttpHeaderName mandatory string
Contains the name of the header.
HttpHeaderValue mandatory string
Contains the value of the header.

SQL Call: Store error (mandatory)

May modify database: Yes

Parameters

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

Not set if the method uses raw responses.
@ResponseXml string
Response of the failed call.

Not set if the method uses raw responses.

SQL Call: Finished (mandatory)

May modify database: No

Parameters

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

Resultset: Forwarding definitions (optional)

Table count: repeated zero or more times
Row count: exactly one row

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 Cancel in an ADMIN_FORCE dialog (the default being none). This value overrides cancelcidstepsback specified in the query string.
ADMIN_CancelReturnToMenuitem optional string
Jumps back to the menuitem with this alias if the user clicks Cancel in an ADMIN_FORCE dialog (the default being none). If no prior menuitem is found with the given alias, then an error is thrown.
ADMIN_CancelMenuItem optional string
Alias of the menuitem to execute if the user clicks Cancel in an ADMIN_FORCE dialog (the default being none). This value overrides cancelmenuitemid specified in the query string.
ADMIN_CancelMenuItemId optional int
Deprecated. Use ADMIN_CancelMenuItem instead.

Id of the menuitem to execute if the user clicks 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_ReturnToMenuItem optional string
Jumps back to the menu item with this alias after execution. This value overrides any destination specified by the query string. If no prior menu item is found with the given alias, then an error is thrown.
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_ForwardMenuItem optional string
Alias of the menuitem to execute after execution (instead of former menu item). This value overrides any destination specified by the query string.
ADMIN_ForwardMenuItemId optional int
Deprecated. Use ADMIN_ForwardMenuItem instead.

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 into an HTML editor. 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.
Default: The default behavior is to step back inside the popup window and close it if there is nothing to step back to.
ADMIN_ClearHistory optional any
When the value is not NULL all navigation history is cleared and the user can't navigate back. This is only supported when forwarding to another menu item.
ADMIN_RefreshMenu optional bit
Will trigger a reload of the sidebar if the column is anything but NULL.
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: 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.

May modify database: No

Parameters

@Force bit
Set to 1 if the last call to validate parameters used admin_force and the user clicked OK in the OK/Cancel dialog.
@ValidateParams bit
Set to 1 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'.

May modify database: Yes

Resultset: Access permissions

Return whether the user is allowed to visit the menu item with the current parameters.
Table count: 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;

		-- Example: Cancel remaining requests if the response is incorrect
		IF @ResponseValue = -1
		BEGIN
			SELECT
				1 AS [ClearQueue];
		END;
    
		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;

Raw example

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

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

	IF @Action = 'GetRawData'
	BEGIN
		SELECT
			'MyHeader' AS HttpHeaderName,
			'MyValue' AS HttpHeaderValue;

		SELECT
			'application/json' AS ContentType,
			'{ "FirstName": "Adam" }' AS TextContent;
		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 = 'StoreRawResponse'
	BEGIN
		DECLARE @ResponseText nvarchar(max);
		
		IF (SELECT COUNT(*) FROM #Content) > 1
		BEGIN
			RAISERROR('Unexpected multipart reponse.', 16, 1);
		END;

		SELECT
			@ResponseText = TextContent
		FROM 
			#Content;

		IF @HttpStatusCode BETWEEN 200 AND 299
		BEGIN
			EXEC dbo.StoreResponse
				@ResponseText = @ResponseText;
		END;
		ELSE
		BEGIN
			SELECT
				@ErrorMessage = CONCAT('WebServiceCall did not return a success status code. Status code was ', @HttpStatusCode, '. ', @ResponseText);
			EXEC SoftadminApi.Log_LogError
				@LogMessage = @ErrorMessage;
		END;

		RETURN;
	END;

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