C# Class Opc.Ua.ServerBase

A base class for a UA server implementation.
Inheritance: IServerBase, IDisposable
ファイルを表示 Open project: OPCFoundation/UA-.NET Class Usage Examples

Public Methods

Method Description
Dispose ( ) : void

Frees any unmanaged resources.

GetEndpoints ( ) : EndpointDescriptionCollection

Returns the endpoints supported by the server.

RequireEncryption ( EndpointDescription description ) : bool

Specifies if the server requires encryption; if so the server needs to send its certificate to the clients and validate the client certificates

ScheduleIncomingRequest ( IEndpointIncomingRequest request ) : void

Schedules an incoming request.

ServerBase ( ) : System

Initializes object with default values.

Start ( ApplicationConfiguration configuration ) : ServiceHost

Starts the server (called from a IIS host process).

Start ( ApplicationConfiguration configuration ) : void

Starts the server (called from a dedicated host process).

Protected Methods

Method Description
CreateHttpsServiceHost ( ServiceHost>.IDictionary hosts, ApplicationConfiguration configuration, BindingFactory bindingFactory, IList baseAddresses, ApplicationDescription serverDescription, List securityPolicies ) : List

Create a new service host for UA HTTPS.

CreateResponse ( RequestHeader requestHeader, Exception exception ) : ResponseHeader

Creates the response header.

CreateResponse ( RequestHeader requestHeader, StringTable stringTable ) : ResponseHeader

Creates the response header.

CreateResponse ( RequestHeader requestHeader, uint statusCode ) : ResponseHeader

Creates the response header.

CreateServiceHost ( ServerBase server ) : ServiceHost

Creates an instance of the service host.

CreateSinglePolicyServiceHost ( ServiceHost>.IDictionary hosts, ApplicationConfiguration configuration, BindingFactory bindingFactory, IList baseAddresses, ApplicationDescription serverDescription, MessageSecurityMode securityMode, string securityPolicyUri, string basePath ) : List

Create a new service host for protocols that support only one policy per host.

CreateUaTcpServiceHost ( ServiceHost>.IDictionary hosts, ApplicationConfiguration configuration, BindingFactory bindingFactory, IList baseAddresses, ApplicationDescription serverDescription, List securityPolicies ) : List

Create a new service host for UA TCP.

Dispose ( bool disposing ) : void

An overrideable version of the Dispose.

FilterByEndpointUrl ( Uri endpointUrl, IList baseAddresses ) : IList

Filters the list of addresses by the URL that the client provided.

FilterByProfile ( StringCollection profileUris, IList baseAddresses ) : IList

Filters the list of addresses by profile.

GetDiscoveryUrls ( ) : StringCollection

Returns the discovery URLs for the server.

GetEndpointInstance ( ServerBase server ) : EndpointBase

Returns an instance of the endpoint to use.

GetServiceContract ( ) : Type

Returns the service contract to use.

GetUserTokenPolicies ( ApplicationConfiguration configuration, EndpointDescription description ) : UserTokenPolicyCollection

Returns the UserTokenPolicies supported by the server.

InitializeRequestQueue ( ApplicationConfiguration configuration ) : void

Initializes the request queue.

InitializeServiceHosts ( ApplicationConfiguration configuration, BindingFactory bindingFactory, ApplicationDescription &serverDescription, EndpointDescriptionCollection &endpoints ) : IList

Creates the endpoints and creates the hosts.

LoadServerProperties ( ) : ServerProperties

Returns the properties for associated with the server instance.

NormalizeHostname ( string hostname ) : string

Checks for IP address or well known hostnames that map to the computer.

OnServerStarting ( ApplicationConfiguration configuration ) : void

Called before the server starts.

OnServerStopping ( ) : void

Called before the server stops

OnUpdateConfiguration ( ApplicationConfiguration configuration ) : void

Called when the server configuration is changed on disk.

Servers are free to ignore changes if it is difficult/impossible to apply them without a restart.

ProcessRequest ( IEndpointIncomingRequest request, object calldata ) : void

Processes the request.

StartApplication ( ApplicationConfiguration configuration ) : void

Starts the server application.

TranslateApplicationDescription ( Uri clientUrl, ApplicationDescription description, IList baseAddresses, Opc.Ua.LocalizedText applicationName ) : ApplicationDescription

Translates the discovery URLs based on the client url and returns an updated ApplicationDescription.

TranslateEndpointDescriptions ( Uri clientUrl, IList baseAddresses, IList endpoints, ApplicationDescription application ) : EndpointDescriptionCollection

Translates the endpoint descriptions based on the client url and profiles provided.

ValidateRequest ( RequestHeader requestHeader ) : void

Verifies that the request header is valid.

Private Methods

Method Description
GetBestDiscoveryUrl ( Uri clientUrl, BaseAddress baseAddress ) : string

Returns the best discovery URL for the base address based on the URL used by the client.

InitializeBaseAddresses ( ApplicationConfiguration configuration ) : void

Initializes the list of base addresses.

Stop ( ) : void

Method Details

CreateHttpsServiceHost() protected method

Create a new service host for UA HTTPS.
protected CreateHttpsServiceHost ( ServiceHost>.IDictionary hosts, ApplicationConfiguration configuration, BindingFactory bindingFactory, IList baseAddresses, ApplicationDescription serverDescription, List securityPolicies ) : List
hosts ServiceHost>.IDictionary
configuration ApplicationConfiguration
bindingFactory BindingFactory
baseAddresses IList
serverDescription ApplicationDescription
securityPolicies List
return List

CreateResponse() protected method

Creates the response header.
protected CreateResponse ( RequestHeader requestHeader, Exception exception ) : ResponseHeader
requestHeader RequestHeader The object that contains description for the RequestHeader DataType.
exception System.Exception The exception used to create DiagnosticInfo assigned to the ServiceDiagnostics.
return ResponseHeader

CreateResponse() protected method

Creates the response header.
protected CreateResponse ( RequestHeader requestHeader, StringTable stringTable ) : ResponseHeader
requestHeader RequestHeader The object that contains description for the RequestHeader DataType.
stringTable StringTable The thread safe table of string constants.
return ResponseHeader

CreateResponse() protected method

Creates the response header.
If statusCode is bad.
protected CreateResponse ( RequestHeader requestHeader, uint statusCode ) : ResponseHeader
requestHeader RequestHeader The object that contains description for the RequestHeader DataType.
statusCode uint The status code.
return ResponseHeader

CreateServiceHost() protected method

Creates an instance of the service host.
protected CreateServiceHost ( ServerBase server ) : ServiceHost
server ServerBase
return ServiceHost

CreateSinglePolicyServiceHost() protected method

Create a new service host for protocols that support only one policy per host.
protected CreateSinglePolicyServiceHost ( ServiceHost>.IDictionary hosts, ApplicationConfiguration configuration, BindingFactory bindingFactory, IList baseAddresses, ApplicationDescription serverDescription, MessageSecurityMode securityMode, string securityPolicyUri, string basePath ) : List
hosts ServiceHost>.IDictionary The hosts.
configuration ApplicationConfiguration The configuration.
bindingFactory BindingFactory The binding factory.
baseAddresses IList The base addresses.
serverDescription ApplicationDescription The server description.
securityMode MessageSecurityMode The security mode.
securityPolicyUri string The security policy URI.
basePath string The base path to use when constructing the hosts.
return List

CreateUaTcpServiceHost() protected method

Create a new service host for UA TCP.
protected CreateUaTcpServiceHost ( ServiceHost>.IDictionary hosts, ApplicationConfiguration configuration, BindingFactory bindingFactory, IList baseAddresses, ApplicationDescription serverDescription, List securityPolicies ) : List
hosts ServiceHost>.IDictionary
configuration ApplicationConfiguration
bindingFactory BindingFactory
baseAddresses IList
serverDescription ApplicationDescription
securityPolicies List
return List

Dispose() public method

Frees any unmanaged resources.
public Dispose ( ) : void
return void

Dispose() protected method

An overrideable version of the Dispose.
protected Dispose ( bool disposing ) : void
disposing bool
return void

FilterByEndpointUrl() protected method

Filters the list of addresses by the URL that the client provided.
protected FilterByEndpointUrl ( Uri endpointUrl, IList baseAddresses ) : IList
endpointUrl System.Uri
baseAddresses IList
return IList

FilterByProfile() protected method

Filters the list of addresses by profile.
protected FilterByProfile ( StringCollection profileUris, IList baseAddresses ) : IList
profileUris StringCollection
baseAddresses IList
return IList

GetDiscoveryUrls() protected method

Returns the discovery URLs for the server.
protected GetDiscoveryUrls ( ) : StringCollection
return StringCollection

GetEndpointInstance() protected method

Returns an instance of the endpoint to use.
protected GetEndpointInstance ( ServerBase server ) : EndpointBase
server ServerBase
return EndpointBase

GetEndpoints() public method

Returns the endpoints supported by the server.
public GetEndpoints ( ) : EndpointDescriptionCollection
return EndpointDescriptionCollection

GetServiceContract() protected method

Returns the service contract to use.
protected GetServiceContract ( ) : Type
return System.Type

GetUserTokenPolicies() protected method

Returns the UserTokenPolicies supported by the server.
protected GetUserTokenPolicies ( ApplicationConfiguration configuration, EndpointDescription description ) : UserTokenPolicyCollection
configuration ApplicationConfiguration The configuration.
description EndpointDescription The description.
return UserTokenPolicyCollection

InitializeRequestQueue() protected method

Initializes the request queue.
protected InitializeRequestQueue ( ApplicationConfiguration configuration ) : void
configuration ApplicationConfiguration The configuration.
return void

InitializeServiceHosts() protected method

Creates the endpoints and creates the hosts.
protected InitializeServiceHosts ( ApplicationConfiguration configuration, BindingFactory bindingFactory, ApplicationDescription &serverDescription, EndpointDescriptionCollection &endpoints ) : IList
configuration ApplicationConfiguration The object that stores the configurable configuration information for a UA application.
bindingFactory BindingFactory The object of a class that manages a mapping between a URL scheme and a binding.
serverDescription ApplicationDescription The object of the class that contains a description for the ApplicationDescription DataType.
endpoints EndpointDescriptionCollection The collection of objects.
return IList

LoadServerProperties() protected method

Returns the properties for associated with the server instance.
protected LoadServerProperties ( ) : ServerProperties
return ServerProperties

NormalizeHostname() protected method

Checks for IP address or well known hostnames that map to the computer.
protected NormalizeHostname ( string hostname ) : string
hostname string The hostname.
return string

OnServerStarting() protected method

Called before the server starts.
protected OnServerStarting ( ApplicationConfiguration configuration ) : void
configuration ApplicationConfiguration The object that stores the configurable configuration information for a UA application.
return void

OnServerStopping() protected method

Called before the server stops
protected OnServerStopping ( ) : void
return void

OnUpdateConfiguration() protected method

Called when the server configuration is changed on disk.
Servers are free to ignore changes if it is difficult/impossible to apply them without a restart.
protected OnUpdateConfiguration ( ApplicationConfiguration configuration ) : void
configuration ApplicationConfiguration The object that stores the configurable configuration information for a UA application.
return void

ProcessRequest() protected method

Processes the request.
protected ProcessRequest ( IEndpointIncomingRequest request, object calldata ) : void
request IEndpointIncomingRequest The request.
calldata object The calldata passed with the request.
return void

RequireEncryption() public static method

Specifies if the server requires encryption; if so the server needs to send its certificate to the clients and validate the client certificates
public static RequireEncryption ( EndpointDescription description ) : bool
description EndpointDescription The description.
return bool

ScheduleIncomingRequest() public method

Schedules an incoming request.
public ScheduleIncomingRequest ( IEndpointIncomingRequest request ) : void
request IEndpointIncomingRequest The request.
return void

ServerBase() public method

Initializes object with default values.
public ServerBase ( ) : System
return System

Start() public method

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
return ServiceHost

Start() public method

Starts the server (called from a dedicated host process).
public Start ( ApplicationConfiguration configuration ) : void
configuration ApplicationConfiguration The object that stores the configurable configuration /// information for a UA application. ///
return void

StartApplication() protected method

Starts the server application.
protected StartApplication ( ApplicationConfiguration configuration ) : void
configuration ApplicationConfiguration The object that stores the configurable configuration information for a UA application.
return void

TranslateApplicationDescription() protected method

Translates the discovery URLs based on the client url and returns an updated ApplicationDescription.
protected TranslateApplicationDescription ( Uri clientUrl, ApplicationDescription description, IList baseAddresses, Opc.Ua.LocalizedText applicationName ) : ApplicationDescription
clientUrl System.Uri The client URL.
description ApplicationDescription The application description.
baseAddresses IList The base addresses.
applicationName Opc.Ua.LocalizedText The localized application name.
return ApplicationDescription

TranslateEndpointDescriptions() protected method

Translates the endpoint descriptions based on the client url and profiles provided.
protected TranslateEndpointDescriptions ( Uri clientUrl, IList baseAddresses, IList endpoints, ApplicationDescription application ) : EndpointDescriptionCollection
clientUrl System.Uri The client URL.
baseAddresses IList The base addresses.
endpoints IList The endpoints.
application ApplicationDescription The application to use with the endpoints.
return EndpointDescriptionCollection

ValidateRequest() protected method

Verifies that the request header is valid.
protected ValidateRequest ( RequestHeader requestHeader ) : void
requestHeader RequestHeader The object that contains description for the RequestHeader DataType.
return void