Skip Ribbon Commands
Skip to main content
SharePoint

Command Service - Invoke via Web Service Activity

Invoking a Command Using the Invoke Web Service Activity

Before using the Invoke Web Service Activity to execute a Command, you must install the Command Service.  We also recommend you familarize yourself with the Command Service Methods and their parameters.

 

Below is an example configuration of the Invoke Web Service Activity, configured to use the Command Service.  In this case, we are want to automate using a Command to create a new directory named FileRepository on the C: drive of your BPM Server.  To do so manually, you open the Command Prompt on your Server and type: md C:\FileRepository.

 

To create the directory you provide values for the fileName and arguments parameters in a call to the Command Service's Execute Method.  Specifically, you "open the Command Prompt" by supplying the value of the Command Prompt's executable for the fileName argument and you "type: md C:\FileRepository" by providing a value in the argument parameter: md C:\FileRepository.

 

In other words, configure the Web Service to call the Command Service's Execute Method:

 

 

Notice that the Web service location resolves to the Web Services Description Language for the Command Service, located at http://<Server Name>:<Port Number>/Bluespring/CmdService/Service.ashx?WSDL.  From the WSDL, we generate the drop-down menu in the Web method field, consisting of the Methods available from the Command Service and select the Execute method.

 

Configure the input parameters via the Data Mappings: Input screen:

 

 

 

The Invoke Web Service Activity, then, will populate the input parameters, fileName and arguments, with the values from the Source, which in this case are literal values of cmd.exe for the fileName and md C:\FileRepository for the arguments.  These values will initiate a command prompt, i.e. cmd.exe, and then provide md C:\FileRepository for the command therein.  Note as well, we indicated that we specified a timeout value and set the waitTimeout to 45 seconds.

 

You can then use the Data Mappings: Output to include various values returned by the Command Service to populate Data Items in your Process at execution time.  For example, let's assume we want to know when the command to create the directory C:\FileRepository is complete.  To do so, we map the output parameter: EndTime to a Data Item:

 

 

At execution time, the Activity Properties will show this value:

 

Additional Notes

  • Bluespring does not recommend calling a Batch File directly. To initiate a Batch File, set the fileName to cmd.exe and provide the path to the Batch File in the arguments parameter
  • Calls made from the Command Service to a fileName are asynchronous, i.e. the Command Service initiates the command without waiting to ensure the command is completed. While such asynchronous calls ensure that the Command Service is available for the next call, it does mean that a command can run indefinitely on your server. If you are using the Command Service to initiate Batch Files or other actions that may take time, Bluespring recommends recording the Id output parameter and periodically calling the GetJobInfo Method to validate a particular command has completed. After a period of time, such as 1 day, if your command has not completed, you can investigate why the command is taking so long to complete or use the KillJob Method to stop the command from running.
Last modified at 7/31/2020 10:44 AM