示例#1
0
        static void Main(string[] args)
        {
            SsbBinding serviceBinding = new SsbBinding();

            serviceBinding.SqlConnectionString        = Utils.Connectionstring("serviceBinding");
            serviceBinding.UseEncryption              = false;
            serviceBinding.UseActionForSsbMessageType = true;
            serviceBinding.Contract = Utils.ChannelContract;

            var host = new ServiceHost(typeof(OrderService.OrderService));

            host.AddServiceEndpoint(typeof(IOrderService), serviceBinding, Utils.ServiceEndpointAddress);
            host.Open();

            Console.WriteLine("Waiting for service to process messages");
            Console.ReadKey();
        }
示例#2
0
        static void Main(string[] args)
        {
            int i = 0;

            while (true)
            {
                var method = Console.ReadLine();
                if (method == "trigger")
                {
                    var db    = new ssb_dbEntities1();
                    var order = new Order
                    {
                        OrderID      = Guid.NewGuid(),
                        CustomerName = "trigger" + i
                    };
                    db.Orders.Add(order);
                    db.SaveChanges();
                }
                else if (method == "wcf")
                {
                    SsbBinding clientBinding = new SsbBinding();
                    clientBinding.SqlConnectionString        = Utils.Connectionstring("clientBinding");
                    clientBinding.UseEncryption              = false;
                    clientBinding.UseActionForSsbMessageType = true;
                    clientBinding.Contract = Utils.ChannelContract;

                    OrderServiceClient client = new OrderServiceClient(clientBinding, new EndpointAddress(Utils.ServiceEndpointAddress));
                    var order = new OrderService.Proxies.Order
                    {
                        OrderId      = Guid.NewGuid(),
                        CustomerName = "wcf" + i
                    };
                    client.SubmitOrder(order);
                    client.Close();
                }
                i++;
            }
        }