A dynamic web-service call to custom URL. Uses proxy settings defined in application variables PROXY and PROXYBYPASSLOCAL to make the request.
The call is only made if there is a UrlSuffix set in the meta data.
The call is only made if there are headers in the meta 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.
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.
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.
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.
Displays a user friendly error message to the user.
Displays a user friendly success message to the user.
Displays a user friendly success message to the user.
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.
Alias of the menu group to show after execution (instead of former menu item). This value overrides any destination specified by the query string.
Deprecated. Use ADMIN_ForwardMenuGroup instead.
Id of the menu group to show after execution (instead of former menu item). This value overrides any destination specified by the query string.
Deprecated. Use ADMIN_ForwardMenuItem instead.
Id of the menu item to execute after execution (instead of former menu item). This value overrides any destination specified by the query string.
Displays a user friendly error message to the user.
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.
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'.
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;
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;
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 = 200
BEGIN
EXEC dbo.StoreResponse
@ResponseText = @ResponseText;
END;
ELSE
BEGIN
SELECT
@ErrorMessage = CONCAT('WebServiceCall did not return an expected status code. Status code was ', @HttpStatusCode, '. ', @ResponseText);
EXEC SoftadminApi.Log_LogError
@LogMessage = @ErrorMessage;
END;
RETURN;
END;
IF @Action = 'Finished'
BEGIN
RETURN;
END;
END;