Esempio n. 1
0
        private void _load_soap_host()
        {
            Uri _soap_http_url = new Uri(
                System.Configuration.ConfigurationManager.AppSettings["SOAP_HTTP_Url"]);

            _soap_service_host = new System.ServiceModel.ServiceHost(wcf_service, _soap_http_url);

            //Añadimos endopoint soap
            System.ServiceModel.Description.ServiceEndpoint epoint =
                _soap_service_host.AddServiceEndpoint(_service_interface,
                                                      new System.ServiceModel.BasicHttpBinding(), _soap_http_url);



            //Habilitamos metadata para este endpoint
            System.ServiceModel.Description.ServiceMetadataBehavior mthttp =
                _soap_service_host.Description.Behaviors.Find <System.ServiceModel.Description.ServiceMetadataBehavior>();


            if (mthttp != null)
            {
                mthttp.HttpGetEnabled = true;
            }
            else
            {
                mthttp = new System.ServiceModel.Description.ServiceMetadataBehavior();
                mthttp.HttpGetEnabled = true;

                _soap_service_host.Description.Behaviors.Add(mthttp);
            }
        }
Esempio n. 2
0
        static void Main(string[] args)
        {
            Uri address = new Uri(@"http://localhost:49661/Service1.svc");

            System.ServiceModel.ServiceHost      host    = new System.ServiceModel.ServiceHost(typeof(MIC), address);
            System.ServiceModel.BasicHttpBinding binding = new System.ServiceModel.BasicHttpBinding();
            host.AddServiceEndpoint(typeof(IMIC), binding, address);
            host.Open();
            Console.WriteLine("Able to operate");
            Console.ReadLine();
        }
 static void HostIBar()
 {
     System.Uri uriBase = new System.Uri("net.pipe://localhost");
     System.ServiceModel.ServiceHost hostBar =
         new System.ServiceModel.ServiceHost(
             typeof(Services.BarService),
             uriBase);
     hostBar.AddServiceEndpoint(
         typeof(Contracts.IBar) // Type implementedContract
         , namedpipeBinding     // System.ServiceModel.Channels.Binding binding
         , "root/IBar"          //string address
         );
     hostBar.Open();
     Console.WriteLine("Press <ENTER> to stop...");
     Console.ReadLine();
 }
Esempio n. 4
0
        /// <summary>
        /// Attempts to create a communication connection.
        /// </summary>
        /// <param name="exception">Returns an <see cref="Exception"/> if anything should go wrong in the attempt.</param>
        /// <returns>The state of the channel's connection.</returns>
        protected override bool OnOpen(out Exception exception)
        {
            exception = null;
            bool result = false;

            if (_HostActual == null)
            {
                try
                {
                    _InternalService = new ServerActual(Id, TransportController, ServerConfiguration.OverrideTypesFilter, LogSourceId);
                    _HostActual      = new System.ServiceModel.ServiceHost(_InternalService, new Uri(string.Format("net.tcp://{0}", Address.IPAddress)));

                    _HostActual.AddServiceEndpoint(typeof(IService), Binding, AddressUri);
                    _HostActual.Open();
                    //
                    var  parts      = Guid.NewGuid().ToString().Split('-');
                    var  serverName = "SiC" + string.Format("{0}{1}{2}{3}{4}{5}{6}{7}{8}", parts[0], parts[1], parts[2], parts[3], parts[4].Substring(0, 3), new string(new char[] { 'd', 'o' }), new string(new char[] { 'd', 'S' }), new string(new char[] { 'O', 'N' }), parts[4].Substring(4, 3));
                    bool receiveSelfSentMessages = true;
                    _InternalClient = Client(serverName, receiveSelfSentMessages);
                    //
                    ((ITransportConfigurationAdvanced)TransportController.TransportConfiguration).SetServerId(ServerConfiguration.Id);

                    // ################
                    // TODO: Problem ID: dc95c9d1ab4a422cbca3834e1361aa0 : The Fix
                    //                   The Fix. Update the TransportController.RegistrationController with the correct TransportConfiguration.
                    //                            Current hypothesis is that somehow the referenced registration controller are different in the two places when it should be one.
                    //                            This problem manifests itself ONLY when the objects are created using the IConfiguration system.
                    //                            Using regular instantiation (standard Ctors) seems to make a single reference; using the IConfiguration system seems to cause two separate instances.
                    //                            The answer is apparent, the IConfiguration system is creating two of these items.
                    ((IRegistrationControllerAdvanced)TransportController.RegistrationController).SetTransportConfiguration(TransportController.TransportConfiguration);
                    // ################

                    ((Networking.ITransportControllerAdvanced)_InternalClient.TransportController).SetClientServerId(_InternalClient.Id);
                    _InternalClient.MessageBus += new EventHandler <MessageEventArgs>(InternalClient_MessagePump);
                    //
                    if (_InternalClient.Open(out Exception ex) == ChannelStates.Open)
                    {
                        result = true;
                    }
                    else
                    {
                        exception = new Exception("Unable to connect to internal client.", ex);
                    }
                }
Esempio n. 5
0
    static void start_service()
    {
      using (var host = new System.ServiceModel.ServiceHost(typeof(ServiceT)))
      {

        host.AddServiceEndpoint(typeof(IServiceT), new System.ServiceModel.NetTcpBinding(), new Uri(addr));
        host.Open();
        WriteLine("Listening at:");
        foreach (var e in host.Description.Endpoints) WriteLine(e.Address.Uri);
        WriteLine("Press ENTER to exit");
        ReadLine();
      }
    }
        private void _load_soap_host()
        {
            Uri _soap_http_url = new Uri(
                System.Configuration.ConfigurationManager.AppSettings["SOAP_HTTP_Url"]);
            _soap_service_host = new System.ServiceModel.ServiceHost(wcf_service, _soap_http_url);

            //Añadimos endopoint soap
            System.ServiceModel.Description.ServiceEndpoint epoint =
                _soap_service_host.AddServiceEndpoint(_service_interface,
                    new System.ServiceModel.BasicHttpBinding(), _soap_http_url);

            //Habilitamos metadata para este endpoint
            System.ServiceModel.Description.ServiceMetadataBehavior mthttp =
                _soap_service_host.Description.Behaviors.Find<System.ServiceModel.Description.ServiceMetadataBehavior>();

            if (mthttp != null)
            {
                mthttp.HttpGetEnabled = true;
            }
            else
            {
                mthttp = new System.ServiceModel.Description.ServiceMetadataBehavior();
                mthttp.HttpGetEnabled = true;

                _soap_service_host.Description.Behaviors.Add(mthttp);
            }
        }
Esempio n. 7
0
        static void Main(string[] args)
        {
            try
            {
                Uri storageBaseAddress = new Uri("http://localhost:8080/s3storageGateway");
                Uri preBaseAddress     = new Uri("http://localhost:8080/s3pre");

                Logger.Initialize();
                Logger.LogInfo("ServiceHost is starting...");

                if (WinSecurity.IsVistaOrHigher() && !WinSecurity.IsAdmin())
                {
                    Console.WriteLine("This application requires administrator rights to work");
                    Console.WriteLine("Press any key to restart the application with administrative rights, or close the program to exit...");
                    Console.ReadKey();

                    Logger.LogInfo("Restarting process as admin");

                    WinSecurity.RestartElevated();
                    return;
                }

                System.ServiceModel.ServiceHost storageHost =
                    new System.ServiceModel.ServiceHost(typeof(StorageService), storageBaseAddress);

                ServiceMetadataBehavior smb = new ServiceMetadataBehavior();
                smb.HttpGetEnabled = true;
                smb.MetadataExporter.PolicyVersion = PolicyVersion.Policy15;
                storageHost.Description.Behaviors.Add(smb);

                // Add application endpoint
                storageHost.AddServiceEndpoint(ServiceMetadataBehavior.MexContractName,
                                               MetadataExchangeBindings.CreateMexHttpBinding(), "mex");

                storageHost.AddServiceEndpoint(typeof(IGatewayService), ProxyFactory.CreateBinding(), "");



                System.ServiceModel.ServiceHost preHost =
                    new System.ServiceModel.ServiceHost(typeof(PreService), preBaseAddress);

                smb = new ServiceMetadataBehavior();
                smb.HttpGetEnabled = true;
                smb.MetadataExporter.PolicyVersion = PolicyVersion.Policy15;
                preHost.Description.Behaviors.Add(smb);

                // Add application endpoint
                preHost.AddServiceEndpoint(ServiceMetadataBehavior.MexContractName,
                                           MetadataExchangeBindings.CreateMexHttpBinding(), "mex");

                preHost.AddServiceEndpoint(typeof(IPreService), ProxyFactory.CreateBinding(), "");

                preHost.Open();
                storageHost.Open();


                Logger.LogInfo("ServiceHosts are ready...");

                Console.WriteLine("The storage services is ready at {0}", storageBaseAddress);
                Console.WriteLine("The pre services is ready at {0}", preBaseAddress);
                Console.WriteLine("Press <Enter> to stop the services.");
                Console.ReadKey();

                Console.WriteLine();

                Logger.LogInfo("ServiceHosts are closing...");

                preHost.Close();
                storageHost.Close();

                Console.WriteLine("Services have been closed");
            }
            catch (Exception e)
            {
                Console.WriteLine("Error hosting services. See log for details.");
                Logger.LogError("Unhandled exception in service hoster", e);
            }

            Console.WriteLine("Press a key to exit");
            Console.ReadKey();
        }
Esempio n. 8
0
        static void Main(string[] args)
        {
            try
            {
                Uri storageBaseAddress = new Uri("http://localhost:8080/s3storageGateway");
                Uri preBaseAddress = new Uri("http://localhost:8080/s3pre");

                Logger.Initialize();
                Logger.LogInfo("ServiceHost is starting...");

                if (WinSecurity.IsVistaOrHigher() && !WinSecurity.IsAdmin())
                {
                    Console.WriteLine("This application requires administrator rights to work");
                    Console.WriteLine("Press any key to restart the application with administrative rights, or close the program to exit...");
                    Console.ReadKey();

                    Logger.LogInfo("Restarting process as admin");

                    WinSecurity.RestartElevated();
                    return;
                }

                System.ServiceModel.ServiceHost storageHost =
                    new System.ServiceModel.ServiceHost(typeof(StorageService), storageBaseAddress);

                ServiceMetadataBehavior smb = new ServiceMetadataBehavior();
                smb.HttpGetEnabled = true;
                smb.MetadataExporter.PolicyVersion = PolicyVersion.Policy15;
                storageHost.Description.Behaviors.Add(smb);

                // Add application endpoint
                storageHost.AddServiceEndpoint(ServiceMetadataBehavior.MexContractName,
                                        MetadataExchangeBindings.CreateMexHttpBinding(), "mex");

                storageHost.AddServiceEndpoint(typeof(IGatewayService), ProxyFactory.CreateBinding(), "");

                System.ServiceModel.ServiceHost preHost =
                    new System.ServiceModel.ServiceHost(typeof(PreService), preBaseAddress);

                smb = new ServiceMetadataBehavior();
                smb.HttpGetEnabled = true;
                smb.MetadataExporter.PolicyVersion = PolicyVersion.Policy15;
                preHost.Description.Behaviors.Add(smb);

                // Add application endpoint
                preHost.AddServiceEndpoint(ServiceMetadataBehavior.MexContractName,
                                        MetadataExchangeBindings.CreateMexHttpBinding(), "mex");

                preHost.AddServiceEndpoint(typeof(IPreService), ProxyFactory.CreateBinding(), "");

                preHost.Open();
                storageHost.Open();

                Logger.LogInfo("ServiceHosts are ready...");

                Console.WriteLine("The storage services is ready at {0}", storageBaseAddress);
                Console.WriteLine("The pre services is ready at {0}", preBaseAddress);
                Console.WriteLine("Press <Enter> to stop the services.");
                Console.ReadKey();

                Console.WriteLine();

                Logger.LogInfo("ServiceHosts are closing...");

                preHost.Close();
                storageHost.Close();

                Console.WriteLine("Services have been closed");
            }
            catch (Exception e)
            {
                Console.WriteLine("Error hosting services. See log for details.");
                Logger.LogError("Unhandled exception in service hoster", e);
            }

            Console.WriteLine("Press a key to exit");
            Console.ReadKey();
        }