locked
Configuring Workflow Services -- How to configure Workflow Control Endpoint RRS feed

  • Question

  • I'm using VS2012.

    Starting from the "WCF Workflow Service Application" project template, how does one add a Workflow Control Endpoint to the application?

    Every single reference to it that I can find online indicates that you add an <endpoint> node within the <service> node in the web.config file, like so:

    <endpoint address="endpoint_address" binding="basicHttpBinding" kind="workflowControlEndpoint" />

    The problem is, the "WCF Workflow Service Application" project template doesn't put a <service> node in the web.config. You tell it which service to start on launch in the project properties, not a config file.

    So how the heck is it done??? And how do you verify that you've successfully done it? Will the WcfTestClient application be able to use the endpoint, or am I required to use the WorkflowControlClient class?

    Monday, May 23, 2016 3:47 PM

Answers

  • Thanks for the response.

    Just for the sake of anyone else that comes across this issue, this is what to do, starting with a fresh new "WCF Workflow Service Application" project.

    First, Create an interface WorkflowService1.ISvcContract with the operations you want the workflow service to offer. Now right-click the project and select "Import Service Contract...". Find the interface you defined, and import it. (you may have to try building the project before it will show up)

    In the workflow designer for Service1.xamlx, click outside of the workflow so that the properties panel says "System.ServiceModel.Activities.WorkflowService is the selected object. At the bottom of the properties panel is an option for "ImplementedContracts". I clicked the button there, and added WorkflowService1.ISvcContract as an implemented contract.

    If you've imported the interface as a contract, then in the toolbox on the left (from where you drag activities into your workflow), and there should now be a section with receive/reply activities for the imported contract. Make sure to add at least one instance of each operation to the workflow service, otherwise it isn't properly implementing the contract.

    In web.config, add the following within the <system.serviceModel> node:

        <bindings>
          <basicHttpBinding />
        </bindings>
          
        <services>
          <service name="Service1">
            <endpoint binding="basicHttpBinding" contract="ISvcContract" />
            <endpoint contract="System.ServiceModel.Activities.IWorkflowInstanceManagement" 
                      binding="basicHttpBinding" 
                      kind="workflowControlEndpoint" />
          </service>
        </services>
    

    Now, the endpoint URI used for control operations will be the same endpoint URI used for service operations. To verify that it's working, I created a console application project, added the client endpoint to the app.config (with the appropriate URI), and created an instance of WorkflowControlClient using that endpoint configuration.

    Unfortunately, you will need the GUIDs of any instances you want to control, since the workflow control client is incapable of enumerating them (because WF makes basic tasks unreasonably complex). As far as I know, the only way to obtain those GUIDs for your workflow service is to either create a custom Tracking Participant (you can pull GUIDs from the records you receive) or to enable persistence (where the GUID is the "Id" column in the "InstancesTable" table.

    Notes on the above:

    • In the "contract" attribute of the first endpoint in the web.config, it does not seem to work if you use the fully-qualified contract name (e.g. with the namespace). Just use the simple interface name.
    • I have absolutely no idea how the control endpoint would be added if you don't start the service contract-first. It complains if you don't include the "contract" attribute of that endpoint, but I would have no idea what to put in there otherwise.
    • If you need to do this with a service implementing multiple contracts... good luck. No idea whether that would work.
    • Proposed as answer by Angie Xu Wednesday, May 25, 2016 1:17 AM
    • Marked as answer by Angie Xu Tuesday, May 31, 2016 5:45 AM
    Tuesday, May 24, 2016 12:39 PM

All replies

  • Hi,

    The workflow control endpoint allows developers to call control operations to remotely control workflow instances hosted using WorkflowServiceHost. This feature can be used to programmatically perform control operations like suspend, resume, and terminate. 

    According to your description above, I think this might help you:

    WorkflowControlEndpoint for configuration-less XAMLX service             

    Regards,

    Angie                     


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Tuesday, May 24, 2016 8:53 AM
  • Thanks for the response.

    Just for the sake of anyone else that comes across this issue, this is what to do, starting with a fresh new "WCF Workflow Service Application" project.

    First, Create an interface WorkflowService1.ISvcContract with the operations you want the workflow service to offer. Now right-click the project and select "Import Service Contract...". Find the interface you defined, and import it. (you may have to try building the project before it will show up)

    In the workflow designer for Service1.xamlx, click outside of the workflow so that the properties panel says "System.ServiceModel.Activities.WorkflowService is the selected object. At the bottom of the properties panel is an option for "ImplementedContracts". I clicked the button there, and added WorkflowService1.ISvcContract as an implemented contract.

    If you've imported the interface as a contract, then in the toolbox on the left (from where you drag activities into your workflow), and there should now be a section with receive/reply activities for the imported contract. Make sure to add at least one instance of each operation to the workflow service, otherwise it isn't properly implementing the contract.

    In web.config, add the following within the <system.serviceModel> node:

        <bindings>
          <basicHttpBinding />
        </bindings>
          
        <services>
          <service name="Service1">
            <endpoint binding="basicHttpBinding" contract="ISvcContract" />
            <endpoint contract="System.ServiceModel.Activities.IWorkflowInstanceManagement" 
                      binding="basicHttpBinding" 
                      kind="workflowControlEndpoint" />
          </service>
        </services>
    

    Now, the endpoint URI used for control operations will be the same endpoint URI used for service operations. To verify that it's working, I created a console application project, added the client endpoint to the app.config (with the appropriate URI), and created an instance of WorkflowControlClient using that endpoint configuration.

    Unfortunately, you will need the GUIDs of any instances you want to control, since the workflow control client is incapable of enumerating them (because WF makes basic tasks unreasonably complex). As far as I know, the only way to obtain those GUIDs for your workflow service is to either create a custom Tracking Participant (you can pull GUIDs from the records you receive) or to enable persistence (where the GUID is the "Id" column in the "InstancesTable" table.

    Notes on the above:

    • In the "contract" attribute of the first endpoint in the web.config, it does not seem to work if you use the fully-qualified contract name (e.g. with the namespace). Just use the simple interface name.
    • I have absolutely no idea how the control endpoint would be added if you don't start the service contract-first. It complains if you don't include the "contract" attribute of that endpoint, but I would have no idea what to put in there otherwise.
    • If you need to do this with a service implementing multiple contracts... good luck. No idea whether that would work.
    • Proposed as answer by Angie Xu Wednesday, May 25, 2016 1:17 AM
    • Marked as answer by Angie Xu Tuesday, May 31, 2016 5:45 AM
    Tuesday, May 24, 2016 12:39 PM