Opc.Ua.ServerBase.Start C# (CSharp) Méthode

Start() public méthode

Starts the server (called from a IIS host process).
public Start ( ApplicationConfiguration configuration ) : ServiceHost
configuration ApplicationConfiguration The object that stores the configurable configuration information /// for a UA application
Résultat ServiceHost
        public ServiceHost Start(ApplicationConfiguration configuration, params Uri[] baseAddresses)
        {
            if (configuration == null) throw new ArgumentNullException("configuration");

            // do any pre-startup processing
            OnServerStarting(configuration);

            // intialize the request queue from the configuration.
            InitializeRequestQueue(configuration);

            // create the binding factory.
            BindingFactory bindingFactory = BindingFactory.Create(configuration, MessageContext);

            // initialize the base addresses.
            InitializeBaseAddresses(configuration);
            
            // initialize the hosts.
            ApplicationDescription serverDescription = null;
            EndpointDescriptionCollection endpoints = null;

            IList<ServiceHost> hosts = InitializeServiceHosts(
                configuration, 
                bindingFactory,
                out serverDescription,
                out endpoints);
            
            // save discovery information.
            ServerDescription = serverDescription;
            m_endpoints = new ReadOnlyList<EndpointDescription>(endpoints);

            // start the application.
            StartApplication(configuration);
                        
            // the configuration file may specify multiple security policies or non-HTTP protocols
            // which will require multiple service hosts. the default host will be opened by WCF when
            // it is returned from this function. The others must be opened here.
            
            if (hosts == null || hosts.Count == 0)
            {
                throw ServiceResultException.Create(StatusCodes.BadConfigurationError, "The UA server does not have a default host.");
            }

            lock (m_hosts)
            {
                for (int ii = 1; ii < hosts.Count; ii++)
                {
                    hosts[ii].Open();
                    m_hosts.Add(hosts[ii]);
                }
            }

            return hosts[0];
        }

Same methods

ServerBase::Start ( ApplicationConfiguration configuration ) : void

Usage Example

        /// <summary>
        /// Starts the UA server.
        /// </summary>
        /// <param name="server">The server.</param>
        public void Start(ServerBase server)
        {
            m_server = server;

            if (m_applicationConfiguration == null)
            {
                LoadApplicationConfiguration(false);
            }

            if (m_applicationConfiguration.SecurityConfiguration != null && m_applicationConfiguration.SecurityConfiguration.AutoAcceptUntrustedCertificates)
            {
                m_applicationConfiguration.CertificateValidator.CertificateValidation += CertificateValidator_CertificateValidation;
            }
            
            server.Start(m_applicationConfiguration);
        }