Exemplo n.º 1
0
        static void Main(string[] args)
        {
            ItemCounter counter = new ItemCounter();

            using (WebServiceHost host = new WebServiceHost(new StreamingFeedService(counter), new Uri("http://localhost:8000/Service")))
            {
                WebHttpBinding binding = new WebHttpBinding();

                binding.TransferMode = TransferMode.StreamedResponse;
                host.AddServiceEndpoint(typeof(IStreamingFeedService), binding, "Feeds");

                host.Open();

                XmlReader reader = XmlReader.Create("http://localhost:8000/Service/Feeds/StreamedFeed");
                StreamedAtom10FeedFormatter formatter = new StreamedAtom10FeedFormatter(counter);

                Console.WriteLine("Reading stream from server");

                formatter.ReadFrom(reader);
                SyndicationFeed feed = formatter.Feed;

                foreach (SyndicationItem item in feed.Items)
                {
                    //This sample is implemented such that the server will generate an infinite stream of items;
                    //it only stops after the client reads 10 items
                    counter.Increment();
                }

                Console.WriteLine("CLIENT: read total of {0} items", counter.GetCount());
                Console.WriteLine("Press any key to terminate");
                Console.ReadLine();
            }
        }
        public void Start(string[] args)
        {
            HomeModule.Container = AppContext.Container;
            PackagesModule.Container = AppContext.Container;
            InstallationsModule.Container = AppContext.Container;
            LogModule.Container = AppContext.Container;
            ActionsModule.Container = AppContext.Container;
            ConfigurationModule.Container = AppContext.Container;

            Nancy.Json.JsonSettings.MaxJsonLength = 1024*1024*5; // 5mb max

            try
            {
                WebUiAddress = new Uri("http://localhost:9999/");
                _host = new WebServiceHost(new NancyWcfGenericService(), WebUiAddress);
                _host.AddServiceEndpoint(typeof (NancyWcfGenericService), new WebHttpBinding(), "");
                _host.Open();
            }
            catch (Exception ex)
            {
                _logger.Fatal(ex, "could not start listening");
            }

            _logger.Info("Hosting Web interface on: " + WebUiAddress);
        }
Exemplo n.º 3
0
 static void Main(string[] args)
 {
     WebServiceHost host=new WebServiceHost(typeof(OperatingSystemService),new Uri("http://localhost:8013/RESTWebservice/"));
     host.Open();
     Console.ReadKey();
     host.Close();
 }
Exemplo n.º 4
0
        static void Main(string[] args)
        {
            Uri baseAddress = new Uri("http://localhost:8000/");
            ServiceHost selfHost = new WebServiceHost(typeof(MonitorService), baseAddress);

            try
            {
                // Step 3 Add a service endpoint.
                var t = new WebHttpBinding();

                selfHost.AddServiceEndpoint(typeof(IMonitorService), t, "test");
                WebHttpBehavior whb = new WebHttpBehavior();

                // Step 4 Enable metadata exchange.
                ServiceMetadataBehavior smb = new ServiceMetadataBehavior();
                smb.HttpGetEnabled = true;

                selfHost.Description.Behaviors.Add(smb);

                // Step 5 Start the service.
                selfHost.Open();
                Console.WriteLine("The service is ready.");
                Console.WriteLine("Press <ENTER> to terminate service.");
                Console.WriteLine();
                Console.ReadLine();

                // Close the ServiceHostBase to shutdown the service.
                selfHost.Close();
            }
            catch (CommunicationException ce)
            {
                Console.WriteLine("An exception occurred: {0}", ce.Message);
                selfHost.Abort();
            }
        }
        private static void Start(string[] args)
        {
            WebServicesImplementation PureCloudServices = new WebServicesImplementation();
            WebServiceHost _serviceHost = new WebServiceHost(PureCloudServices, new Uri(PureCloudServices.URL));

            _serviceHost.Open();
        }
        public async Task Run(string httpAddress, string listenToken)
        {
            using (var host = new WebServiceHost(this.GetType()))
            {
                var webHttpRelayBinding = new WebHttpRelayBinding(EndToEndWebHttpSecurityMode.Transport,
                                                                  RelayClientAuthenticationType.RelayAccessToken)
                                                                 {IsDynamic = false};
                host.AddServiceEndpoint(this.GetType(),
                    webHttpRelayBinding,
                    httpAddress)
                    .EndpointBehaviors.Add(
                        new TransportClientEndpointBehavior(
                            TokenProvider.CreateSharedAccessSignatureTokenProvider(listenToken)));

                host.Open();

                Console.WriteLine("Copy the following address into a browser to see the image: ");
                Console.WriteLine(httpAddress + "/Image");
                Console.WriteLine();
                Console.WriteLine("Press [Enter] to exit");
                Console.ReadLine();

                host.Close();
            }
        }
Exemplo n.º 7
0
        static void Main(string[] args)
        {
            WebServiceHost webServiceHost = new WebServiceHost(typeof(PartyService.Service));

            WebHttpBinding serviceBinding = new WebHttpBinding(WebHttpSecurityMode.TransportCredentialOnly);
            serviceBinding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Basic;
            ServiceEndpoint ep = webServiceHost.AddServiceEndpoint(
                typeof(PartyService.IService),
                serviceBinding,
                "http://localhost:8000/service");
            ep.Behaviors.Add(new PartyService.ProcessorBehaviour());

            WebHttpBinding staticBinding = new WebHttpBinding(WebHttpSecurityMode.None);
            ServiceEndpoint sep = webServiceHost.AddServiceEndpoint(
                typeof(PartyService.IStaticItemService),
                new WebHttpBinding(),
                "http://localhost:8000");

            webServiceHost.Credentials.UserNameAuthentication.UserNamePasswordValidationMode = UserNamePasswordValidationMode.Custom;
            webServiceHost.Credentials.UserNameAuthentication.CustomUserNamePasswordValidator = new PartyService.Validator();
            webServiceHost.Description.Behaviors.Find<ServiceDebugBehavior>().IncludeExceptionDetailInFaults = true;

            webServiceHost.Open();
            Console.WriteLine("Service is running - press enter to quit");
            Console.ReadLine();
            webServiceHost.Close();
            Console.WriteLine("Service stopped");
        }
Exemplo n.º 8
0
		static void Main (string[] args) {
			LegoRestService DemoServices = new LegoRestService ();
			WebServiceHost _serviceHost = new WebServiceHost (DemoServices, new Uri ("http://localhost:8000/DEMOService"));
			_serviceHost.Open ();
			Console.ReadKey ();
			_serviceHost.Close ();
		}
Exemplo n.º 9
0
 public void StartWebService()
 {
     //BasicConfigurator.Configure( new PatternLayout("%d [%t] %-5p %c %m%n"), @".\test.txt");
     RestDemoServices DemoServices = new RestDemoServices();
     WebServiceHost _serviceHost = new WebServiceHost(DemoServices, new Uri(URL));
     _serviceHost.Open();
 }
Exemplo n.º 10
0
        protected override void OnStart(string[] args)
        {
            var sn = "Facturador Fiscal Winks Hotel";

            try
            {
                Uri baseAddress = new Uri(ConfigurationManager.AppSettings["BaseAddress"]);

                var webHost = new WebServiceHost(typeof(ServiceSelector), baseAddress);
                var endpoint = webHost.AddServiceEndpoint(typeof(IServiceSelector), new WebHttpBinding(WebHttpSecurityMode.None), baseAddress);
                //add support for cors (both for the endpoint to detect and create reply)
                endpoint.Behaviors.Add(new CorsBehaviorAttribute());

                foreach (var operation in endpoint.Contract.Operations)
                {
                    //add support for cors (and for operation to be able to not
                    //invoke the operation if we have a preflight cors request)
                    operation.Behaviors.Add(new CorsBehaviorAttribute());
                }

                webHost.Open();
            }
            catch (Exception ex)
            {
                if (!EventLog.SourceExists(sn))
                    EventLog.CreateEventSource(sn, "Application");

                EventLog.WriteEntry(sn, ex.Message, EventLogEntryType.Error);
            }
        }
Exemplo n.º 11
0
        static void StartControlService(ManualResetEvent quitEvent)
        {
            try {

                string uriStr = string.Format ("http://localhost:{0}/{1}"
                                              , Properties.Settings.Default.ControlServicePort
                                              , Properties.Settings.Default.ControlServicePath);

                System.Diagnostics.Debug.WriteLine (string.Format ("Starting control service ({0}) ..."), uriStr);

                ControlService crawlerControlService = new ControlService ();
                crawlerControlService.QuitEvent = quitEvent;

                var serviceHost = new WebServiceHost (crawlerControlService, new Uri (uriStr));

                serviceHost.Open ();

                System.Diagnostics.Debug.WriteLine (string.Format ("Control service running."));

            } catch (Exception ex) {

                LogEx (ex);
                throw;
            }
        }
        public async Task Run(string hostName, string listenToken)
        {
            string httpAddress = new UriBuilder("http", hostName, -1, "svc").ToString();
            using (var host = new WebServiceHost(GetType()))
            {
                host.AddServiceEndpoint(
                    GetType(),
                    new WebHttpRelayBinding(
                        EndToEndWebHttpSecurityMode.None,
                        RelayClientAuthenticationType.None) {IsDynamic = true},
                    httpAddress)
                    .EndpointBehaviors.Add(
                        new TransportClientEndpointBehavior(
                            TokenProvider.CreateSharedAccessSignatureTokenProvider(listenToken)));

                host.Open();

                Console.WriteLine("Starting a browser to see the image: ");
                Console.WriteLine(httpAddress + "/Image");
                Console.WriteLine();
                // launching the browser
                System.Diagnostics.Process.Start(httpAddress + "/Image");
                Console.WriteLine("Press [Enter] to exit");
                Console.ReadLine();

                host.Close();
            }
        }
Exemplo n.º 13
0
 public static WebServiceHost Create(Uri baseUri, AppDelegate app)
 {
     var host = new WebServiceHost(new GateWcfService(app), baseUri);
     host.AddServiceEndpoint(typeof (GateWcfService), new WebHttpBinding(), "");
     host.Open();
     return host;
 }
Exemplo n.º 14
0
        static void Main()
        {
            //Create Users
            UserDB.AddUser(new User("u1", "p1","1"));
            UserDB.AddUser(new User("u2", "p2","2"));
            UserDB.AddUser(new User("u3", "p3","3"));

            //Start BackOfficeService
            var backOfficeCallBackServiceHost = new WebServiceHost(typeof(BackOfficeCallBackService));
            backOfficeCallBackServiceHost.Open();

            //Start REST WebSiteService
            var webSiteServer = new WebServiceHost(typeof(WebSiteService));
            webSiteServer.Open();

            //Create timer to check messageQueue Outbox
            var myTimer = new Timer();
            myTimer.Elapsed += LookForDownloadReady;
            myTimer.Interval = 5;
            myTimer.Enabled = true;

            Console.ReadLine();

            //Meter aqui os closes dos servicos nos fim
        }
 protected override void OnStart(string[] args)
 {
     var host = new WebServiceHost(new NancyWcfGenericService(),
                       new Uri("http://localhost:1234/base/"));
      host.AddServiceEndpoint(typeof(NancyWcfGenericService), new WebHttpBinding(), "");
      host.Open();
 }
Exemplo n.º 16
0
        public static void Run()
        {
            //return;
            if (System.IO.File.Exists("Config-Web.xml"))
            {
                if (!System.IO.File.Exists("Config-Client.xml"))
                    throw new InvalidOperationException("WebService cannot start without client support");

                WebServiceHost host;
                ServiceEndpoint endpoint;

                //start web server :)
                host = new WebServiceHost(typeof (Service), new Uri("http://localhost.com:9000/"));
                    //todo: move to config
                endpoint = host.AddServiceEndpoint(typeof (IService), new WebHttpBinding(), "service");
                host.Open();
                hosts.Add(host);
                endpoints.Add(endpoint);

                host = new WebServiceHost(typeof (AccountService), new Uri("http://localhost.com:9000/"));
                    //todo: move to config
                endpoint = host.AddServiceEndpoint(typeof (IAccountService), new WebHttpBinding(), "account");
                host.Open();
                hosts.Add(host);
                endpoints.Add(endpoint);

                Running = true;
            }
        }
Exemplo n.º 17
0
        /// <summary>
        /// OSA Plugin Interface - called on start up to allow plugin to do any tasks it needs
        /// </summary>
        /// <param name="pluginName">The name of the plugin from the system</param>
        public override void RunInterface(string pluginName)
        {
            pName = pluginName;

            try
            {
                this.Log.Info("Starting Rest Interface");

                bool showHelp = bool.Parse(OSAEObjectPropertyManager.GetObjectPropertyValue(pName, "Show Help").Value);

                serviceHost = new WebServiceHost(typeof(OSAERest.api), new Uri("http://localhost:8732/api"));
                WebHttpBinding binding = new WebHttpBinding(WebHttpSecurityMode.None);
                binding.CrossDomainScriptAccessEnabled = true;

                var endpoint = serviceHost.AddServiceEndpoint(typeof(IRestService), binding, "");

                ServiceDebugBehavior sdb = serviceHost.Description.Behaviors.Find<ServiceDebugBehavior>();
                sdb.HttpHelpPageEnabled = false;

                if (showHelp)
                {
                    serviceHost.Description.Endpoints[0].Behaviors.Add(new WebHttpBehavior { HelpEnabled = true });
                }

                this.Log.Info("Starting Rest Interface");
                serviceHost.Open();
            }
            catch (Exception ex)
            {
                this.Log.Error("Error starting RESTful web service", ex);
            }
        }
Exemplo n.º 18
0
        public void GetTodosFiltered()
        {
            using (var server = new WebServiceHost(new TodoService(), new Uri(_hostAddress)))
            using (var client = new WebChannelFactory<ITodoApi>(new WebHttpBinding(), new Uri(_hostAddress)))
            {
                server.Open();
                client.Open();
                var channel = client.CreateChannel();

                using (new OperationContextScope((IContextChannel)channel))
                {
                    var todos = channel.GetTodosFiltered(true);
                    ValidateHttpStatusResponse(HttpStatusCode.OK);

                    Assert.AreEqual(1, todos.Todo.Length);
                }

                using (new OperationContextScope((IContextChannel)channel))
                {
                    var todos = channel.GetTodosFiltered(false);
                    ValidateHttpStatusResponse(HttpStatusCode.OK);

                    Assert.AreEqual(2, todos.Todo.Length);
                }
            }
        }
Exemplo n.º 19
0
        private static void Two()
        {
            Console.WriteLine("Starting service...");

            // Configure the credentials through an endpoint behavior.
            TransportClientEndpointBehavior relayCredentials = new TransportClientEndpointBehavior();
            relayCredentials.TokenProvider =
              TokenProvider.CreateSharedAccessSignatureTokenProvider("RootManageSharedAccessKey", "fBLL/4/+rEsCOiTQPNPS6DJQybykqE2HdVBsILrzMLY=");

            // Create the binding with default settings.
            WebHttpRelayBinding binding = new WebHttpRelayBinding();

            binding.Security.RelayClientAuthenticationType = RelayClientAuthenticationType.None;
            // Get the service address.
            // Use the https scheme because by default the binding uses SSL for transport security.
            Uri address = ServiceBusEnvironment.CreateServiceUri("https", "johnsonwangnz", "Rest");

            // Create the web service host.
            WebServiceHost host = new WebServiceHost(typeof(EchoRestService), address);
            // Add the service endpoint with the WS2007HttpRelayBinding.
            host.AddServiceEndpoint(typeof(IEchoRestContract), binding, address);

            // Add the credentials through the endpoint behavior.
            host.Description.Endpoints[0].Behaviors.Add(relayCredentials);

            // Start the service.
            host.Open();

            Console.WriteLine("Listening...");

            Console.ReadLine();
            host.Close();
        }
Exemplo n.º 20
0
 protected static void StartService()
 {
     BindRequestToProcessors();
     var address = new Uri(_settings.JsonServiceAddress);
     _jsonService = new WebServiceHost(typeof(JsonServicePerCall), address);
     _jsonService.Open();
 }
Exemplo n.º 21
0
        public Form()
        {
            try
            {
                InitializeComponent();

                DBProvider.CreateDBIfNotExist();
                dataGridView.DataSource = Source;

                SystemEvents.SessionSwitch += Tracker.SessionSwitch;
                SystemEvents.SessionSwitch += LoadGridSource;

                Tracker.SessionSwitch(null, new SessionSwitchEventArgs(SessionSwitchReason.SessionLogon));
                LoadGridSource(null, null);

                SetViewSettings();
                //init host for test client
                var host = new WebServiceHost(typeof(Service), new Uri("http://localhost:8001/"));
                var ep = host.AddServiceEndpoint(typeof(IService), new WebHttpBinding(), "");
                host.Open();
            }
            catch (Exception ex)
            {
                Logger.Log(ex);
            }
        }
Exemplo n.º 22
0
        static void Main(string[] args)
        {
            // Before running replace the servicebus namespace (next line) and REPLACESERVICEBUSKEY (app.config)
            string serviceNamespace = "jtarquino";
            string serviceBusKey = "REPLACEKEYHERE";
            Console.Write("Your Service Namespace: ");

            // Tranport level security is required for all *RelayBindings; hence, using https is required
            Uri address = ServiceBusEnvironment.CreateServiceUri("https", serviceNamespace, "Timer");

            WebServiceHost host = new WebServiceHost(typeof(ProblemSolver), address);

            WebHttpRelayBinding binding = new WebHttpRelayBinding(EndToEndWebHttpSecurityMode.None, RelayClientAuthenticationType.None);

            host.AddServiceEndpoint(
               typeof(IProblemSolver), binding, address)
                .Behaviors.Add(new TransportClientEndpointBehavior
                {
                    TokenProvider = TokenProvider.CreateSharedAccessSignatureTokenProvider("RootManageSharedAccessKey", serviceBusKey)
                });

            host.Open();
            Console.WriteLine(address + "CurrentTime");
            Console.WriteLine("Press ENTER to close");
            Console.ReadLine();

            host.Close();
        }
Exemplo n.º 23
0
        public static void Create()
        {
            var settings = new ConfigSettings();

            var anonHost = new WebServiceHost(new NancyWcfGenericService(new AnonymousBootstrapper(settings)), new Uri(settings.HostUri));
            anonHost.AddServiceEndpoint(typeof (NancyWcfGenericService), new WebHttpBinding(), string.Empty);
            anonHost.Open();
        }
        public void SetUp()
        {
            requestFactory = this.CreateRequestFactory();

            webServiceHost = new WebServiceHost(typeof(TestService), new Uri(BASE_URL));
            this.ConfigureWebServiceHost(webServiceHost);
            webServiceHost.Open();
        }
 public IDisposable Create(Func<IDictionary<string, object>, Task> app, IDictionary<string, object> properties)
 {
     var host = new WebServiceHost(new DispatcherService(app));
     var ep = host.AddServiceEndpoint(typeof(DispatcherService), GetBinding(), _config.Address);
     ep.Behaviors.Add(_config.GetTransportBehavior());
     host.Open();
     return host;
 }
Exemplo n.º 26
0
 static void Main(string[] args)
 {
     // var webServiceHost = new ServiceHost(typeof(Machine));
     var webServiceHost = new WebServiceHost(typeof(Machine), new Uri("http://localhost:8080/RESTWcf"));
     webServiceHost.Open();
     Console.ReadLine();
     webServiceHost.Close();
 }
        public void SetUp()
        {
            template = new RestTemplate(uri);
            contentType = new MediaType("text", "plain");

            webServiceHost = new WebServiceHost(typeof(TestService), new Uri(uri));
            webServiceHost.Open();
        }
Exemplo n.º 28
0
 static void Binding3()
 {
     using (WebServiceHost webHost = new WebServiceHost(typeof (EmployeeService)))
     {
         webHost.Open();
         Console.Read();
     }
 }
        public void SetUp()
        {
            template = new RestTemplate(uri);
            template.MessageConverters = new List<IHttpMessageConverter>();

            webServiceHost = new WebServiceHost(typeof(TestService), new Uri(uri));
            webServiceHost.Open();
        }
Exemplo n.º 30
0
	public static void Main() {
	
		var host = new WebServiceHost( typeof (SOM), new Uri("http://spb9503:8080/som") );
		host.Open();
	
		Thread.Sleep( 60 * 60 * 1000 ); 
	
	}