Self
|
public class SelfHostingService : Adapter, ISelfHostingService, IAdapter, ISupportLifecycle, IDisposable, IProvideStatus, IPersistSettings, IPolicyRetriever
The SelfHostingService type exposes the following members.
Name | Description | |
---|---|---|
SelfHostingService | Initializes a new instance of the web service. |
Name | Description | |
---|---|---|
AllowCrossDomainAccess | Gets or sets flag that indicates if web services will enable cross-domain access for Silverlight and Flash applications. | |
AllowedDomainList | Gets or sets comma separated list of allowed domains when AllowCrossDomainAccess is true. Use * for domain wildcards, e.g., *.consoto.com. | |
AutomaticFormatSelectionEnabled | Gets or sets a value that determines if automatic format selection is enabled for Web HTTP bindings. | |
ContractInterface | Gets or sets the FullName of the contract interface implemented by the web service. | |
DefaultOutgoingRequestFormat | Gets and sets the default outgoing request format for Web HTTP bindings. | |
DefaultOutgoingResponseFormat | Gets and sets the default outgoing response format for Web HTTP bindings. | |
Domain |
Gets the AppDomain in which the Adapter is executing.
(Inherited from Adapter) | |
Enabled |
Gets or sets a boolean value that indicates whether the web service is currently enabled.
(Overrides AdapterEnabled) | |
Endpoints | Gets or sets a semicolon delimited list of URIs where the web service can be accessed. | |
FaultExceptionEnabled | Gets or sets the flag that specifies whether a FaultException is generated when an internal server error(HTTP status code: 500) occurs for Web HTTP bindings. | |
HostFile |
Gets or sets the path to the file where the Adapter is housed.
(Inherited from Adapter) | |
IsDisposed |
Gets a flag that indicates whether the object has been disposed.
(Inherited from Adapter) | |
JsonFaultHandlingEnabled | Gets or sets a value that determines if JSON formatted fault messages should be returned during exceptions. | |
MemoryUsage |
Gets the memory utilization of the Adapter in bytes if executing in a separate AppDomain, otherwise NaN.
(Inherited from Adapter) | |
Name |
Gets the unique identifier of the Adapter.
(Inherited from Adapter) | |
PersistSettings |
Gets or sets a boolean value that indicates whether Adapter settings are to be saved to the config file.
(Inherited from Adapter) | |
ProcessorUsage |
Gets the % processor utilization of the Adapter if executing in a separate AppDomain otherwise NaN.
(Inherited from Adapter) | |
PublishMetadata | Gets or sets a boolean value that indicates whether web service metadata is to made available at all web service Endpoints. | |
SecurityPolicy | Gets or sets the FullName of IAuthorizationPolicy to be used for securing all web service Endpoints. | |
ServiceEnabled | Gets or sets a boolean value that indicates whether the web service is to be enabled at startup. | |
ServiceHost | Gets the WebServiceHost hosting the web service. | |
SettingsCategory |
Gets or sets the category under which Adapter settings are to be saved to the config file if the PersistSettings property is set to true.
(Inherited from Adapter) | |
Singleton | Gets or sets a boolean value that indicates whether the ServiceHost will use the current instance of the web service for processing requests or base the web service instance creation on InstanceContextMode specified in its ServiceBehaviorAttribute. | |
Status |
Gets the descriptive status of the Adapter.
(Inherited from Adapter) | |
TypeName |
Gets or sets the text representation of the Adapter's TypeName.
(Inherited from Adapter) | |
WindowsAuthentication | Gets or sets a boolean value that indicates whether Windows Authentication is to be enabled. |
Name | Description | |
---|---|---|
CreateObjRef | Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object. (Inherited from MarshalByRefObject) | |
Dispose |
Releases all the resources used by the Adapter.
(Inherited from Adapter) | |
Dispose(Boolean) |
Releases the unmanaged resources used by the web service and optionally releases the managed resources.
(Overrides AdapterDispose(Boolean)) | |
Equals | Determines whether the specified object is equal to the current object. (Inherited from Object) | |
Finalize |
Releases the unmanaged resources before the Adapter is reclaimed by GC.
(Inherited from Adapter) | |
GetFlashPolicy | Gets policy stream for Flash applications. | |
GetHashCode | Serves as the default hash function. (Inherited from Object) | |
GetLifetimeService | Retrieves the current lifetime service object that controls the lifetime policy for this instance. (Inherited from MarshalByRefObject) | |
GetServiceAddress | Gets an address where the ServiceHost will host the service. | |
GetSilverlightPolicy | Gets policy stream for Silverlight applications. | |
GetType | Gets the Type of the current instance. (Inherited from Object) | |
GetUnusedPort | Get an unused port number. | |
Initialize |
Initializes the web service.
(Overrides AdapterInitialize) | |
InitializeLifetimeService | Obtains a lifetime service object to control the lifetime policy for this instance. (Inherited from MarshalByRefObject) | |
InitializeServiceHost | Initializes the ServiceHost. | |
LoadSettings |
Loads saved web service settings from the config file if the PersistSettings property is set to true.
(Overrides AdapterLoadSettings) | |
MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object) | |
MemberwiseClone(Boolean) | Creates a shallow copy of the current MarshalByRefObject object. (Inherited from MarshalByRefObject) | |
OnDisposed |
Raises the Disposed event.
(Inherited from Adapter) | |
OnExecutionException |
Raises the ExecutionException event.
(Inherited from Adapter) | |
OnServiceHostCreated | Raises the ServiceHostCreated event. | |
OnServiceHostStarted | Raises the ServiceHostStarted event. | |
OnServiceProcessException | Raises the ServiceProcessException event. | |
OnStatusUpdate |
Raises the StatusUpdate event.
(Inherited from Adapter) | |
SaveSettings |
Saves web service settings to the config file if the PersistSettings property is set to true.
(Overrides AdapterSaveSettings) | |
ToString | Returns a string that represents the current object. (Inherited from Object) |
Name | Description | |
---|---|---|
Disposed |
Occurs when Adapter is disposed.
(Inherited from Adapter) | |
ExecutionException |
Occurs when the IAdapter encounters an Exception during execution.
(Inherited from Adapter) | |
ServiceHostCreated | Occurs when the ServiceHost has been created with the specified Endpoints. | |
ServiceHostStarted | Occurs when the ServiceHost has can process requests via all of its endpoints. | |
ServiceProcessException | Occurs when an Exception is encountered when processing a request. | |
StatusUpdate |
Occurs when the Adapter wants to provide a status update.
(Inherited from Adapter) |
Name | Description | |
---|---|---|
GetEnumValueOrDefault |
Gets the enumeration constant for value, if defined in the enumeration, or a default value.
(Defined by EnumExtensions) | |
GetEnumValueOrDefaultT |
Gets the enumeration constant for this value, if defined in the enumeration, or a default value.
(Defined by EnumExtensions) |
using System.ServiceModel; using System.ServiceModel.Web; using GSF.ServiceModel; namespace Services { [ServiceContract()] public interface IService : ISelfHostingService { [OperationContract(), WebGet(UriTemplate = "/hello/{name}")] string Hello(string name); } public class Service : SelfHostingService, IService { public string Hello(string name) { return string.Format("Hello {0}!", name); } } }
using System; using System.ServiceModel; using System.ServiceModel.Description; using System.ServiceModel.Web; using Services; using GSF.ServiceModel; class Program { static void Main(string[] args) { // Initialize web service. Service service = new Service(); service.PublishMetadata = true; service.Endpoints = "http.soap11://localhost:4500/soap; http.rest://localhost:4500/rest"; service.Initialize(); // Show web service status. if (service.ServiceHost.State == CommunicationState.Opened) { Console.WriteLine("\r\n{0} is running:", service.GetType().Name); foreach (ServiceEndpoint endpoint in service.ServiceHost.Description.Endpoints) { Console.WriteLine("- {0} ({1})", endpoint.Address, endpoint.Binding.GetType().Name); } Console.Write("\r\nPress Enter key to stop..."); } else { Console.WriteLine("\r\n{0} could not be started", service.GetType().Name); } // Shutdown. Console.ReadLine(); service.Dispose(); } }
<?xml version="1.0"?> <configuration> <system.serviceModel> <services> <service name="Services.Service"> <endpoint address="soap" contract="Services.IService" binding="basicHttpBinding"/> <endpoint address="rest" contract="Services.IService" binding="webHttpBinding" behaviorConfiguration="restBehavior"/> </service> </services> <behaviors> <serviceBehaviors> <behavior> <serviceMetadata httpGetEnabled="true"/> </behavior> </serviceBehaviors> <endpointBehaviors> <behavior name="restBehavior"> <webHttp helpEnabled="true"/> </behavior> </endpointBehaviors> </behaviors> <serviceHostingEnvironment multipleSiteBindingsEnabled="true"> <serviceActivations> <add relativeAddress="Service.svc" service="Services.Service, Services"/> </serviceActivations> </serviceHostingEnvironment> </system.serviceModel> </configuration>