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

Question

Question

How do I make the Workflow Rest API service reference endpoint "dynamic"?

asked on April 1, 2016 Show version history

When using the non-rest API, I was doing this:

string workflowServer = "localhost";
string workflowApplication = "My Custom Workflow Application";
using (WorkflowConnection connection = WorkflowConnection.CreateConnection(workflowServer, workflowApplication))

This gave me the ability to switch out the value of workflowServer with a value in my web.config file.

Using the Rest API though, the service reference is added by specifying the location of the web service, e.g. "http://localhost/Workflow/api/RestWorkflowAPI.svc"

Which is fine for the development environment, but when the app is deployed the administrator needs to be able to change the host name to something other than localhost, since their WF server may not be on the same server as the web app.

How is this accomplished? I know how to read/write values from/into a config file, I just don't know how to update a service reference's endpoint.

0 0

Answer

SELECTED ANSWER
replied on April 2, 2016

Figured it out. Looks like the Workflow Rest API allows overriding the endpoint specified in the service reference.

var config = WebConfigurationManager.OpenWebConfiguration("~");
string endpoint = config.AppSettings.Settings["WorkflowWebURL"].Value + "/api/RestWorkflowAPI.svc";
System.ServiceModel.EndpointAddress address = new System.ServiceModel.EndpointAddress(endpoint);

    using (WorkflowAPIBaseClient WorkflowService = new WorkflowAPIBaseClient())
    {
        WorkflowService.Endpoint.Address = address;
        InstanceCreationData creationData = new InstanceCreationData();
        creationData.Initiator = new InstanceUserData();
        creationData.Initiator.InitiatorName = "Admin";
        WorkflowService.CreateWorkflowInstance(workflowName, creationData);
    }

You'll need to add a reference to System.Web.Configuration to be able to read from web.config.

0 0
replied on August 15, 2019

hi Ege Ersoz, it is necessary to connect with a full user, could the wfagente user be used without a license?

 

        creationData.Initiator.InitiatorName = "wfagente";

 

Very grateful for your support. thank you

0 0

Replies

replied on April 1, 2016

This is not really a Laserfiche question. Try something like this suggestion.

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

Sign in to reply to this post.