STEM help

8.7.7 Advanced web service configuration

There are several advanced configuration options that you may change by altering the STEMWebService.asmx file that is installed on your server as explained in 8.7.4 Installing the web service. You will need to use a plain text editor to alter the STEMWebService.asmx as described below. (For example, the Notepad editor that comes with Windows, and not a rich text editor such as WordPad or Microsoft Word that might add formatting commands to the text.)

The start of the STEMWebService.asmx file looks like this:

<%@ WebService Language="C#" Class="STEMWebService" %>
// STEM Version 7.4.1

using System;
using System.Web.Services;

[WebService(Namespace="http://www.impliedlogic.com/")]
public class STEMWebService : STEMWebServiceLib.STEMWebService
{

Where any instructions below ask you to copy and paste additional code into the file, do so on a new line immediately after the final { in this quoted section.

Setting the offline files location

By default, the web service expects to find the ‘offline’ files described elsewhere in these instructions in a folder named ‘offline’ that sits in the same parent folder as the folder containing STEMWebService.asmx. If your offline folder is in some other location, you can tell the web service this by finding the following line in STEMWebService.asmx and deleting the // at the start of it, then changing the file path highlighted below to refer to your offline folder’s name and location relative to the STEMWebService.asmx file. For the computer to understand the file path it is important that you replace each single backslash in the path with a double backslash.

// protected override string OfflineLocation { get { return "..\\offline"; } }

Using non-default user name providers

By default, the web service will use the user name provided by your web server’s normal identity control. Unfortunately, if your page doesn’t require a log-in, this means that the web service will not know the identity of any user and so will generate a new randomly-named user data folder for each new request to run a model. It also means that if you use a non-standard login system the web service might not be able to identify users.

If you wish to override this behaviour, find the line below and delete the // from the start of it. Then replace the User.Identity.Name with whatever C# code determines the accurate username on your server.

// protected override string AuthenticatedUserName { get { return User.Identity.Name; } }

For testing, you may simply want to make the web service think that all users are logged in with a single user name. However, be aware that this will then mean that two users simultaneously using the web service will have their files mixed up, possibly giving unusual or broken results, and that any data saved by one user will be available to all other users. For example, to make the web service think that all users are logged in with the username "TestingUser":

// protected override string AuthenticatedUserName { get { return "TestingUser"; } }

Allowing for long model runs

The stem.dll process that coordinates the running of models on eSTEM is designed to terminate itself when not in use to save on resources. This means that in an eSTEM environment where the STEM Editor and Results program are not running it will terminate itself 30 seconds after receiving the most recent command. If a single stage of the running of your model takes longer than 30 seconds then this can cause stem.dll to exit prematurely, causing your model run to fail.

You can alter this behaviour to use a longer timeout period by finding the line below, deleting the // from the start of it and then changing the 30 value to a larger number (this is the time in seconds between activity checks). If you make this number too large you will waste resources on a rarely used server by having stem.dll remain in memory between model runs.

// protected override uint TimeInSecondsBetweenStemDllUseChecks { get { return 30; } }

Setting the maximum input size

The maximum size of a single input value is limited to 10,000 characters to avoid the possibility of accidental or malicious sending of massive inputs causing excessive resource consumption on the server. This should be more than enough for most inputs but it is possible that you might have a very large interpolated series input that needs a larger allowance. In this case, you can increase the limit by copying and pasting this line into your STEMWebService.asmx file and then changing the highlighted 10000 value to the limit you would like to apply (the maximum value that will work is 2147483647, but we would recommend increasing the limit by as little as you can):

protected virtual int MaximumInputValueLength { get { return 10000; } }

 

© Implied Logic Limited