protected internal override ServiceEndpoint CreateServiceEndpoint(ContractDescription contractDescription)
        {
            WorkflowControlEndpoint result = new WorkflowControlEndpoint();

            if (!string.IsNullOrEmpty(this.Binding))
            {
                Binding binding = ConfigLoader.LookupBinding(this.Binding, this.BindingConfiguration);

                // we need to add validation here
                if (binding == null)
                {
                    throw FxTrace.Exception.AsError(new ConfigurationErrorsException(SR.FailedToLoadBindingInControlEndpoint(this.Binding, this.BindingConfiguration, this.Name)));
                }

                result.Binding = binding;
            }

            // This is only for client side
            if (this.shouldLetConfigLoaderOverwriteAddress)
            {
                // ConfigLoader will check for null and overwrite it with the address from ChannelEndpointElement
                result.Address = null;
            }

            return(result);
        }
예제 #2
0
        static void Main()
        {
            // Same workflow as Dataflow sample
            Activity            workflow = LoadProgram("Dataflow.xaml");
            WorkflowServiceHost host     = new WorkflowServiceHost(workflow,
                                                                   new Uri("http://localhost/Dataflow.xaml"));

            WorkflowControlEndpoint controlEndpoint = new WorkflowControlEndpoint(
                new BasicHttpBinding(),
                new EndpointAddress(new Uri("http://localhost/DataflowControl.xaml")));

            CreationEndpoint creationEndpoint = new CreationEndpoint(
                new BasicHttpBinding(),
                new EndpointAddress(new Uri("http://localhost/DataflowControl.xaml/Creation")));

            host.AddServiceEndpoint(controlEndpoint);
            host.AddServiceEndpoint(creationEndpoint);

            host.Open();

            Console.WriteLine("Host open...");

            IWorkflowCreation creationClient = new ChannelFactory <IWorkflowCreation>(creationEndpoint.Binding, creationEndpoint.Address).CreateChannel();

            // Start a new instance of the workflow
            Guid instanceId = creationClient.CreateSuspended(null);
            WorkflowControlClient controlClient = new WorkflowControlClient(controlEndpoint);

            controlClient.Unsuspend(instanceId);

            Console.WriteLine("Hit any key to exit Host...");
            Console.ReadLine();
        }
예제 #3
0
파일: client.cs 프로젝트: zhimaqiao51/docs
 static void Snippet2()
 {
     // <Snippet2>
     WorkflowControlEndpoint wce           = new WorkflowControlEndpoint(new BasicHttpBinding(), new EndpointAddress(new Uri("http://localhost/DataflowControl.xaml")));
     WorkflowControlClient   controlClient = new WorkflowControlClient(wce);
     // </Snippet2>
 }
예제 #4
0
        public static WorkflowServiceHost CreateWorkflowServiceHost()
        {
            WorkflowService service = new WorkflowService()
            {
                Body = PurchaseOrderWorkflow.CreateBody(),

                Endpoints =
                {
                    new System.ServiceModel.Endpoint
                    {
                        Binding             = new System.ServiceModel.NetMsmqBinding("NetMsmqBindingTx"),
                        AddressUri          = new Uri("net.msmq://localhost/private/ReceiveTx"),
                        ServiceContractName = XName.Get(PurchaseOrderWorkflow.poContractDescription.Name)
                    }
                }
            };

            WorkflowServiceHost workflowServiceHost = new WorkflowServiceHost(service);

            IServiceBehavior idleBehavior = new WorkflowIdleBehavior {
                TimeToUnload = TimeSpan.Zero
            };

            workflowServiceHost.Description.Behaviors.Add(idleBehavior);

            IServiceBehavior workflowUnhandledExceptionBehavior = new WorkflowUnhandledExceptionBehavior()
            {
                Action = WorkflowUnhandledExceptionAction.AbandonAndSuspend
            };

            workflowServiceHost.Description.Behaviors.Add(workflowUnhandledExceptionBehavior);

            SqlWorkflowInstanceStoreBehavior instanceStoreBehavior = new SqlWorkflowInstanceStoreBehavior()
            {
                ConnectionString = "Server=localhost\\SQLEXPRESS;Integrated Security=true;Initial Catalog=DefaultSampleStore;"
            };

            workflowServiceHost.Description.Behaviors.Add(instanceStoreBehavior);

            ServiceEndpoint workflowControlEndpoint = new WorkflowControlEndpoint()
            {
                Binding = new System.ServiceModel.NetNamedPipeBinding(System.ServiceModel.NetNamedPipeSecurityMode.None),
                Address = new System.ServiceModel.EndpointAddress("net.pipe://workflowInstanceControl")
            };

            workflowServiceHost.AddServiceEndpoint(workflowControlEndpoint);
            workflowServiceHost.WorkflowExtensions.Add(new TrackingListenerConsole());

            foreach (ServiceEndpoint ep in workflowServiceHost.Description.Endpoints)
            {
                Console.WriteLine(ep.Address);
            }

            return(workflowServiceHost);
        }
예제 #5
0
        protected internal override ServiceEndpoint CreateServiceEndpoint(ContractDescription contractDescription)
        {
            WorkflowControlEndpoint endpoint = new WorkflowControlEndpoint();

            if (!string.IsNullOrEmpty(this.Binding))
            {
                System.ServiceModel.Channels.Binding binding = ConfigLoader.LookupBinding(this.Binding, this.BindingConfiguration);
                if (binding == null)
                {
                    throw FxTrace.Exception.AsError(new ConfigurationErrorsException(System.ServiceModel.Activities.SR.FailedToLoadBindingInControlEndpoint(this.Binding, this.BindingConfiguration, base.Name)));
                }
                endpoint.Binding = binding;
            }
            return(endpoint);
        }
        static void Main()
        {
            // Same workflow as Dataflow sample
            Activity            workflow = LoadProgram("Dataflow.xaml");
            WorkflowServiceHost host     = new WorkflowServiceHost(workflow,
                                                                   new Uri("http://localhost/Dataflow.xaml"));

            host.Description.Behaviors.Add(new SqlWorkflowInstanceStoreBehavior
            {
                ConnectionString                 = ConfigurationManager.ConnectionStrings["persistenceStore"].ConnectionString,
                InstanceEncodingOption           = InstanceEncodingOption.None,
                InstanceCompletionAction         = InstanceCompletionAction.DeleteAll,
                InstanceLockedExceptionAction    = InstanceLockedExceptionAction.NoRetry,
                HostLockRenewalPeriod            = new TimeSpan(0, 0, 30),
                RunnableInstancesDetectionPeriod = new TimeSpan(0, 0, 5)
            });

            WorkflowControlEndpoint controlEndpoint = new WorkflowControlEndpoint(
                new BasicHttpBinding(),
                new EndpointAddress(new Uri("http://localhost/DataflowControl.xaml")));

            CreationEndpoint creationEndpoint = new CreationEndpoint(
                new BasicHttpBinding(),
                new EndpointAddress(new Uri("http://localhost/DataflowControl.xaml/Creation")));


            host.AddServiceEndpoint(controlEndpoint);
            host.AddServiceEndpoint(creationEndpoint);

            host.Open();

            Console.WriteLine("Host open...");

            IWorkflowCreation creationClient = new ChannelFactory <IWorkflowCreation>(creationEndpoint.Binding, creationEndpoint.Address).CreateChannel();

            // Start a new instance of the workflow
            Guid instanceId = creationClient.CreateSuspended(null);
            WorkflowControlClient controlClient = new WorkflowControlClient(controlEndpoint);

            controlClient.Unsuspend(instanceId);

            Console.WriteLine("Hit any key to exit Host...");
            Console.ReadLine();
        }
예제 #7
0
        // start the service
        static void Main(string[] args)
        {
            string persistenceConnectionString = ConfigurationManager.ConnectionStrings["WorkflowPersistence"].ConnectionString;
            string baseAddr = "http://localhost:8080/Contoso/HiringRequestService";

            using (WorkflowServiceHost host = new WorkflowServiceHost(new HiringRequestProcessServiceDefinition(), new Uri(baseAddr)))
            {
                SqlWorkflowInstanceStoreBehavior instanceStoreBehavior = new SqlWorkflowInstanceStoreBehavior(persistenceConnectionString);
                instanceStoreBehavior.InstanceCompletionAction = InstanceCompletionAction.DeleteAll;
                instanceStoreBehavior.InstanceEncodingOption   = InstanceEncodingOption.GZip;

                host.Description.Behaviors.Add(instanceStoreBehavior);
                host.Description.Behaviors.Add(new WorkflowIdleBehavior()
                {
                    TimeToPersist = new TimeSpan(0)
                });

                host.WorkflowExtensions.Add(new HiringRequestInfoPersistenceParticipant());

                // configure the unknown message handler
                host.UnknownMessageReceived += new EventHandler <System.ServiceModel.UnknownMessageReceivedEventArgs>(Program.UnknownMessageReceive);

                // add the control endpoint
                WorkflowControlEndpoint publicEndpoint = new WorkflowControlEndpoint(
                    new BasicHttpBinding(),
                    new EndpointAddress(new Uri("http://127.0.0.1/hiringProcess")));
                host.AddServiceEndpoint(publicEndpoint);
                host.AddDefaultEndpoints();

                // start the service
                Console.WriteLine("Starting ...");

                host.Open();

                // end when the user hits enter
                Console.WriteLine("Service is waiting at: " + baseAddr);
                Console.WriteLine("Press [Enter] to exit");
                Console.ReadLine();
                host.Close();
            }
        }