Examples
In each of the following example snippits, the vertical ellipsis denotes the assignment of additional data items that have been omitted. Otherwise, these only omit error handling and the setting of configuration information, such as the destination server name.
C#
using NewtonSoft.Json;
using SAWaves.SimTransIF.Client;
WebClient client = new WebClient(SharedId, ServerUri);
Sn80 transaction = new Sn80();
transaction.TransactionId = "X101";
transaction.Token = client.Token;
⋮
string jsonTransaction = JsonConvert.SerializeObject(transaction);
client.Send("Sn80", jsonTransaction);
In the above snippit, SharedId
is an ID that is created at installation and typically stored in a configuration file. However, it can be hard coded into the application, if desired.
ServerUri
is the SimTransIF server's end point URI. It too, would normally be obtained from a configuration file.
Powershell
$Type = Add-Type -AssemblyName "\Program Files\SA_Waves\SimTransIF\Client.dll" -PassThru
$Client = NewObject SAWaves.SimTransIF.Client.WebClient -ArgumentList $SharedId, $ServerUri
$Transaction = NewObject SAWaves.SimTransIF.Client.Sn80
$Transaction.TransactionId = "X101"
$Transaction.Token = $Client.Token
⋮
$JsonTransaction = ConvertTo-Json $transaction
$Client.Send("Sn80" $JsonTransaction)
$SharedId
is an ID that is created at installation. $ServerUri
is the SimTransIF server's end point URI. Both would typically be obtained from a configuration file, but could be hard coded.
Javascript
On the web page, add a button and script module, such as:
<button id-"sendSn60" onclick="sendSn60();">Send SN60</&button>
<script type="module" src="scripts/sendSn60.js"></script>
The sendSn60.js file resembles:
import * as data from "./commonData-plain.js"
import {WebClient} from "./WebClient-plain.js"
function sendSn60() {
let client = new WebClient(ServerUri);
const request = async () => {
client.SharedId = sharedId
let token = await client.GetToken();
client.Token = token;
let sn60 = new data.Sn60();
sn60.TransactionId = "tx003";
sn60.Token = token;
⋮
await client.Send("SN60", JSON.stringify(sn60));
}
request();
}
window.sendSn60 = sendSn60;
In the above snippit, sharedId
is an ID that is created at installation and typically stored in a configuration file. However, it can be hard coded into the application, if desired.
ServerUri
is the SimTransIF server's end point URI. It too, would normally be obtained from a configuration file.