Пример #1
0
        static void Main(string[] args)
        {
            ObjectFactory.Initialize(x =>
            {
                x.IgnoreStructureMapConfig = true;
            });

            var typeFactory = new StructureMapServiceTypeFactory();

            var serviceAspectFactory = new ServiceAspectFactory(typeFactory);
            serviceAspectFactory.Register(Assembly.GetExecutingAssembly());

            var serviceOperationProfileLoader = new ServiceOperationProfileLoader(typeFactory, serviceAspectFactory);

            var xmlRequestRouter = new XmlRequestRouter(serviceOperationProfileLoader);

            xmlRequestRouter.Register(Assembly.GetExecutingAssembly());

            using (var listener = new HttpRequestListener("http://localhost/Public/Xml/", xmlRequestRouter))
            {
                var choice = 0;
                var sessionId = Guid.NewGuid();
                var requestNames = new[] { "TestRequest", "Testing", "Testing2" };

                Console.WriteLine("Press space to send request");

                while (true)
                {
                    var key = Console.ReadKey();

                    if (key.Key == ConsoleKey.Spacebar)
                    {
                        var requestName = requestNames[choice++ % requestNames.Length];
                        var testRequest = new TestRequest { UserName = "******", SessionId = sessionId, Question = "Is there anybody out there?" };

                        Console.WriteLine();
                        Console.WriteLine("Request = {0}", testRequest.Question);

                        var testResponse = SendRequest(requestName, testRequest);

                        if (testResponse.Error == null)
                        {
                            Console.WriteLine("Response = {0}", testResponse.Answer);
                        }
                        else
                        {
                            Console.WriteLine("Error : {0} {1}", testResponse.Error.Code, testResponse.Error.Message);
                            Console.WriteLine("Error StackTrace:");
                            Console.WriteLine(testResponse.Error.StackTrace);
                        }
                    }
                    else
                    {
                        break;
                    }
                }
            }
        }
Пример #2
0
        public void Test()
        {
            var typeFactory = new StructureMapServiceTypeFactory();

            var serviceAspectFactory = new ServiceAspectFactory(typeFactory);

            serviceAspectFactory.Register(Assembly.GetExecutingAssembly());

            var serviceOperationProfileLoader = new ServiceOperationProfileLoader(typeFactory, serviceAspectFactory);

            var xmlRequestRouter = new XmlRequestRouter(serviceOperationProfileLoader);

            xmlRequestRouter.Register(Assembly.GetExecutingAssembly());
        }