Please enable JavaScript to view this site.

Altova MapForce Server 2020 Advanced Edition

The following example illustrates how to run a mapping execution file (.mfx) from VBScript code. On Windows, the example files are available at the following path: C:\Program Files\Altova\MapForceServer2020\etc\Examples.

 

Before running the code below, ensure the following prerequisites are met:

 

MapForce Server is installed and licensed

MapForce Server is available as a COM server object (normally, this process takes place automatically during MapForce Server installation; to check if registration was successful, see About the COM Interface).

 

Option Explicit

 

'Create a MapForce Server object; use "MapForce_x64.Server" if you want to use the 64-bit installation

Dim objMFS

Set objMFS = WScript.GetObject( """MapForce.Server" )

 

'Set a working directory - used as a base for relative paths (you may need to adapt the path to the installation folder)

objMFS.WorkingDirectory = "C:\Program Files (x86)\Altova\MapForceServer2020\etc\Examples"

 

'Default path to the MapForce Server executable is the installation path (same dir with the MapForceServer.dll)

'In case you moved the binaries on the disk, you need to explicitly set the path to the .exe file

'objMFS.ServerPath = "C:\Program Files (x86)\Altova\MapForceServer2020\bin\MapForceServer.exe"

 

'Set global resource file and configuration, if your mapping uses global resources

'Call objMFS.SetOption("globalresourcefile", "GlobalResource.xml") '"gr" can be used as short name for "globalresourcefile"

'Call objMFS.SetOption("globalresourceconfig", "Config2") '"gc" can be used as short name for "globalresourceconfig"

 

'Prepare the parameters, if your mapping uses parameters

'Call objMFS.AddParameter( "testparam1", "value 1" )

 

' Run the mapping; input and output paths are stored inside the MFX file

' NOTE Please adapt the path to the input file in order to run the sample

If ( objMFS.Run( "C:\Program Files (x86)\Altova\MapForceServer2020\etc\Examples\TokenizeString.mfx" ) ) Then

 WScript.Echo( "Success - finished execution" )

Else

 WScript.Echo( objMFS.LastExecutionMessage )

End If

© 2019 Altova GmbH