You are viewing limited content. For full access, please sign in.

Question

Question

REST API - Workflow Web Service

asked on February 3, 2015

Hi!  I've been in about a 12-hr rabbit hole and just can't figure how to do a couple of things.

Does anyone know how to do any of the following?

1. Pass input parameters via REST API?

2. Receive output parameters via REST or Workflow Web Service?

 


 

0 0

Answer

APPROVED ANSWER
replied on April 2

Adding to this old thread for searchability. I made a post here that describes the Workflow Web Service REST API endpoint, how to access the local API documentation, and with an attached working example of two workflows you can import to your own system and test out:

https://answers.laserfiche.com/questions/168986/Discussion-Will-Laserfiche-ever-get-a-unified-RESTful-HTTP-API#200102

0 0

Replies

replied on February 9, 2015 Show version history

Hi Rich! Here is the code you can use to Create an instance of a workflow named "Workflow 1" with 2 input parameters (for Workflow Web Service version 9.2):

           using (WorkflowAPIBaseClient workflowService = new WorkflowAPIBaseClient())
           {
                InstanceCreationData instanceData = new InstanceCreationData();
                instanceData.ParameterCollection = new InstanceParameterCollection();
                InstanceParameterData paramData1 = new InstanceParameterData();
                paramData1.Name = "TestIn1";
                paramData1.Value = "xyz";
                instanceData.ParameterCollection.Add(paramData1);                
                InstanceParameterData paramData2 = new InstanceParameterData();
                paramData2.Name = "TestIn2";
                paramData2.Value = "987";
                instanceData.ParameterCollection.Add(paramData2);
                InstanceCreationResultData result = workflowService.CreateWorkflowInstance("Workflow 1", instanceData);                                              
            }

 

Note that "result" does not hold the actual result of the workflow, but rather information about the workflow instance you created (such as the instance ID). This makes sense, since the call only starts an instance, and does not wait for it to finish. 

At the moment, you cannot use the Workflow Web Service itself to acquire the results of the completed workflow (such as the output params). If you know when your Workflow is done, you can still use the good-ole Workflow SDK (WFSO) to get your Workflow instances though, and then maybe make a callback to the calling service with that. There are other ways of doing this kind of thing too, though the Workflow Web Service itself does not support the functionality, as it's mostly there to create instances of Workflows. 

 

I could add to this. We have a mechanism that Workflow uses to provide a post-completion callback after an instance completes. This is used internally (for example, by the Workflow->Forms integration). As a note, this mechanism might seem a tad bit complicated and, while it is supported, it's not officially supported and thus it's not documented (but I was asked to share it anyways =)).

After a Workflow completes, it can make a callback to a WebService of your choice, established by using the following 3 "hidden" input parameters:

$SyncMethod = WebService
$SyncWebAddress = [your url]
$SyncData = [whatever data you want]
 
Here you can use these configurations to configure a callback that is invoked after a Workflow terminates. Upon termination, the Workflow will make a POST request to the url provided into SyncWebAddress. Various headers are also included with this (I can post more info here on this if you'd like, though I recommend debugging it first-hand). However, this mostly serves to notify your application that a WF completed or terminated so you can then process it (such as using WFSO or something). Again, this particular feature is kind of hidden and not documented anywhere else that I know of =).
 
Edit: I was informed that output parameters are actually written in xml to the body of the request mentioned above. Might be worth checking it out. 
2 0
replied on June 28, 2018

I'm writing a web service using the "hidden" parameters specified above.  I'm not able to get the $SyncData to come back.  I don't see it as a header value and the body is being populated with the XML for the output parameters as you had mentioned.  Can you please let me know how to get the $SyncData returned in the callback URL?

 

Thank you

1 0
replied on February 4, 2020

Hey Flavio!!

 

Again - another great and well-informed post. Would you mind showing/sharing additional details related to the above with "$Sync--"? Or possibly throwing up an image or two within the workflow to demonstrate it, just like you did for the Google API one por favor? smiley

0 0
replied on October 19, 2020

interesting topic here ... I manage to "read" portion of code that setting the callback URL, code snippets like:

           if (!string.IsNullOrEmpty(submissionData.CallbackURL) && Uri.TryCreate(submissionData.CallbackURL, UriKind.Absolute, out result))
            {
              instanceParameters.Add(new InstanceParameter("$SycnMethod", "WebService"));
              instanceParameters.Add(new InstanceParameter("$SyncWebAddress", result.ToString()));
              instanceParameters.Add(new InstanceParameter("$SyncData", string.Empty));
            }

 

However, need to know where this callback being called in which class. 

Any idea?

 

0 0
replied on February 9, 2015 Show version history
There are two places to find this information.
  1. The Consuming the Workflow Web Service whitepaper describes how to consume the web service in Visual Studio, which provides objects to make calling the service easy. There are screenshots and an object list in the paper.
  2. If you visit http://localhost/Workflow/api/help/operations/CreateInstance on the server with your Workflow Web Service, you'll get a reference page for how to create a workflow instance, including how to pass parameters. 

 

If you're going the other direction (i.e. from Workflow to your web service), you'll want to take a look at the web service activities in Workflow: HTTP Form Post and HTTP Web Request. 

1 0
replied on February 5, 2015

Hey there,

 

Do you mean via a .Net solution,, another workflow or a URL in a web browser?

 

-Ben

0 0
replied on February 28, 2015

Thanks for your input, guys!

I ended up having my workflow posting back to an MVC controller that wrote the results to MSMQ, which the initiating call would monitor after calling the Workflow Web Service.

0 0
You are not allowed to follow up in this post.

Sign in to reply to this post.