locked
Possible to get Multiple Operations (workflows) on one service? RRS feed

  • Question

  •  

    I'd like to get something like this:

       http://localhost:8082/MyService

    with multiple operations:

    Workflow1(), Workflow2(), etc

    So that in the client, the code would look something like this:

    var proxy = new ServiceReference1.ServiceClient();

    var data1 = proxy.Workflow1();

    var data2 = proxy.Workflow2();

    Is that possible?  Advisable??  How do I go about this if it is possible and advisable??

    I'm setting up my services in code like this currently, but can't get more than 1 operation on a service:

                 try

                 {

                     string baseAddress = "http://localhost:8082/";

                     Uri address = null;

                     Activity workflow = null;

                     WorkflowServiceHost host = null;

                     address = new Uri(baseAddress + "MyService");

                     workflow = new Workflow1();

                     host = new WorkflowServiceHost(workflow, address);

                     host.Description.Behaviors.Add(new ServiceMetadataBehavior() { HttpGetEnabled = true });

                     host.Open();

                     WorkflowServicesHosts.Add(host);

                     workflow = new WorkflowServices.Workflow2();

                     address = new Uri(baseAddress + "Workflow2");

                     host = new WorkflowServiceHost(workflow, address);

                     host.Open();

                     WorkflowServicesHosts.Add(host);

                     foreach(WorkflowServiceHost wfsh in WorkflowServicesHosts)

                     {

                         Console.WriteLine(wfsh.Description.Name);

                     }

     

    TIA,

     

    George

     

    Monday, October 18, 2010 12:36 AM

Answers

  • George,

    Basically, your solution can be managed by a Virtual Contract (untyped message) and workflow service for mediating each operation. The Virtual Contract must be created using a Contract-First model. The wsdl metadata can be stored in the Repository or as a local resource for its exporting by service.

    Note, that the client will create a proxy based on the Contract-First model, not from the physical service.

     

     

    Thanks

    Roman


    Roman Kiss, MVP Connected System Developer
    • Proposed as answer by Andrew_Zhu Wednesday, October 20, 2010 7:39 AM
    • Marked as answer by geoGruven Wednesday, October 20, 2010 10:13 AM
    Monday, October 18, 2010 11:38 PM

All replies

  • you have to configure the Receive activity's OperationName and ServiceContractName property. If two Receive activity have same ServiceContractName and different OperationName, it will create a ServiceContract with multiple operations for you.
    Monday, October 18, 2010 7:21 AM
  • Thanks for your quick reply Juyu.  Currently, my Receive Activitys do have the same ServiceContractName ({http://tempuri.org/}IService) with different OperationNames. (MyService, Workflow2)

    Is the C# code in my original question correct?  I've tried a couple of different strategies and this works, but I end up with 2 ServiceProxys each with one Operation.

    Again, my goal is 1 ServiceProxy with many Operations.

    Thanks,

    George

    Monday, October 18, 2010 1:08 PM
  • George,

    I'm not really sure if you can do it by creating two separate hosts, but I think you can do it by putting the two service workflows as children of a single parallel [or better: pick] activity (so siblings of each other), and then hosting it in a single WorkflowServiceHost. In that case they would get hosted on the same address, but I'm guessing that is fine(?).

    Tim

    Edit: Whoops, just realized I probably should have recommended Pick activity instead of Parallel.
    Tim

    Monday, October 18, 2010 6:29 PM
  • Hi,

    To do this you will need to create a third WCF service that calls the two workflow services depending on the method called. It may be possible to de something clever with the routing service.

    Regards,

    Alan

     


    http://www.CloudCasts.net - Community Webcasts Powered by Azure
    • Proposed as answer by Andrew_Zhu Wednesday, October 20, 2010 7:39 AM
    Monday, October 18, 2010 7:59 PM
  • Thanks Tim and Allan for your replies.

    My project will have tens of Operations and I was hopeful that I could place all those Operations on one WorkflowServiceHost.

    I think placing tens of receive operations in one parallel activity or one WCF endpoint that ‘picks’ the correct workflow would work but might be more complicated that just creating 1 Activity and one WorkflowServiceHost per operation using a factory method.

    Thanks again for your help,

    George

    Monday, October 18, 2010 8:55 PM
  • George,

    Basically, your solution can be managed by a Virtual Contract (untyped message) and workflow service for mediating each operation. The Virtual Contract must be created using a Contract-First model. The wsdl metadata can be stored in the Repository or as a local resource for its exporting by service.

    Note, that the client will create a proxy based on the Contract-First model, not from the physical service.

     

     

    Thanks

    Roman


    Roman Kiss, MVP Connected System Developer
    • Proposed as answer by Andrew_Zhu Wednesday, October 20, 2010 7:39 AM
    • Marked as answer by geoGruven Wednesday, October 20, 2010 10:13 AM
    Monday, October 18, 2010 11:38 PM