本文整理汇总了C#中System.ServiceModel.Web.WebServiceHost.Abort方法的典型用法代码示例。如果您正苦于以下问题:C# WebServiceHost.Abort方法的具体用法?C# WebServiceHost.Abort怎么用?C# WebServiceHost.Abort使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.ServiceModel.Web.WebServiceHost
的用法示例。
在下文中一共展示了WebServiceHost.Abort方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
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();
}
}
示例2: Main
static void Main(string[] args)
{
WebServiceHost webHost = null;
try
{
webHost = new WebServiceHost(typeof(CarRentalService), new Uri("http://localhost:1234"));
webHost.Open();
Console.WriteLine("Web service host is open...");
Console.ReadLine();
}
catch(Exception ex)
{
if (webHost != null) webHost.Abort();
Console.WriteLine(ex.ToString());
}
}
示例3: Main
static void Main(string[] args)
{
var host = new WebServiceHost(typeof(RestService), new Uri(RestUri));
try
{
host.AddServiceEndpoint(typeof(IRestService), new WebHttpBinding(), "");
host.Open();
Console.WriteLine("Press <ENTER> to terminate");
Console.ReadLine();
host.Close();
}
catch (CommunicationException e)
{
Console.WriteLine("An exception occurred: {0}", e.Message);
host.Abort();
}
}
示例4: Main
static void Main(string[] args)
{
WebServiceHost host = new WebServiceHost(typeof(Service), new Uri("http://localhost:8000/"));
try
{
ServiceEndpoint ep = host.AddServiceEndpoint(typeof(IService), new WebHttpBinding(), "");
host.Open();
using (ChannelFactory<IService> cf = new ChannelFactory<IService>(new WebHttpBinding(), "http://localhost:8000"))
{
cf.Endpoint.Behaviors.Add(new WebHttpBehavior());
IService channel = cf.CreateChannel();
object s;
Console.WriteLine("Calling EchoWithGet via HTTP GET: ");
s = channel.EchoWithGet("Hello, world");
Console.WriteLine(" Output: {0}", s);
Console.WriteLine("");
Console.WriteLine("This can also be accomplished by navigating to");
Console.WriteLine("http://localhost:8000/EchoWithGet?s=Hello, world!");
Console.WriteLine("in a web browser while this sample is running.");
Console.WriteLine("");
Console.WriteLine("Calling EchoWithPost via HTTP POST: ");
s = channel.EchoWithPost("Hello, world");
Console.WriteLine(" Output: {0}", s);
Console.WriteLine("");
}
Console.WriteLine("Press <ENTER> to terminate");
Console.ReadLine();
host.Close();
}
catch (CommunicationException cex)
{
Console.WriteLine("An exception occurred: {0}", cex.Message);
host.Abort();
}
}
示例5: Main
static void Main(string[] args)
{
var host = new System.ServiceModel.Web.WebServiceHost(typeof(EvalService));
try
{
host.Open();
foreach (var endpoint in host.Description.Endpoints)
{
Console.WriteLine(endpoint.Address.ToString());
}
Console.WriteLine("EvalService is up and running");
Console.ReadLine();
host.Close();
}
catch (Exception e)
{
Console.WriteLine(e);
host.Abort();
}
}
示例6: Main
static void Main(string[] args)
{
var host = new WebServiceHost(typeof(EvalService));
try
{
host.Open();
PrintServiceInfo(host);
Console.WriteLine();
Console.WriteLine("Press [ENTER] to shutdown the server...");
Console.ReadLine();
host.Close();
}
catch (Exception e)
{
Console.WriteLine(e);
host.Abort();
}
}
示例7: Main
static void Main(string[] args)
{
Uri baseAddress = new Uri("http://localhost:9876/");
//WebServiceHost svcHost = new WebServiceHost(typeof(AATodo.CalcService), baseAddress);
WebServiceHost svcHost = new WebServiceHost(new AATodoService(), baseAddress);
try
{
svcHost.Open();
Console.WriteLine("Service is running at " + baseAddress);
Console.WriteLine("Press enter to quit...");
Console.ReadLine();
svcHost.Close();
}
catch (CommunicationException cex)
{
Console.WriteLine("An exception occurred: {0}", cex.Message);
svcHost.Abort();
}
}
示例8: TestService
public TestService(Type serviceType)
{
for (int i = 0; i < 100; i++)
{
int hostId = Interlocked.Increment(ref s_lastHostId);
_serviceUri = new Uri("http://" + Environment.MachineName + "/Temporary_Listen_Addresses/MongoTestService" + hostId.ToString() + "/");
_host = new WebServiceHost(serviceType, _serviceUri);
try
{
_host.Open();
break;
}
catch (Exception)
{
_host.Abort();
_host = null;
}
}
if (_host == null)
{
throw new InvalidOperationException("Could not open a service even after 100 tries.");
}
}
示例9: SetupWebServiceSilverlight
private bool SetupWebServiceSilverlight()
{
Uri webServiceAddress = new Uri("http://localhost:" + SLWCFPort.ToString() + "/");
m_webHostSilverlight = new WebServiceHost(typeof(WebServiceSilverlight), webServiceAddress);
try
{
WebHttpBinding binding = new WebHttpBinding(WebHttpSecurityMode.TransportCredentialOnly);
ServiceEndpoint endpoint = m_webHostSilverlight.AddServiceEndpoint(typeof(IPolicyRetriever), binding, "");
m_webHostSilverlight.SetEndpointAddress(endpoint, "");
m_webHostSilverlight.Open();
}
catch (CommunicationException ex)
{
Console.WriteLine("An exception occurred: {0}", ex.Message);
m_webHostSilverlight.Abort();
return false;
}
return true;
}
示例10: SetupWebService
private bool SetupWebService()
{
Uri webServiceAddress = new Uri("http://localhost:" + WCFPort.ToString() + "/SEServerExtender/Web/");
m_webHost = new WebServiceHost(typeof(WebService), webServiceAddress);
try
{
//WebHttpBinding binding = new WebHttpBinding(WebHttpSecurityMode.TransportCredentialOnly);
//binding.Security.Mode = WebHttpSecurityMode.TransportCredentialOnly;
//binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Windows;
//ServiceEndpoint endpoint = m_webHost.AddServiceEndpoint(typeof(IWebServiceContract), binding, "WebService");
//m_webHost.Credentials.UserNameAuthentication.UserNamePasswordValidationMode = UserNamePasswordValidationMode.Custom;
//m_webHost.Credentials.UserNameAuthentication.CustomUserNamePasswordValidator = new UserNameValidator();
EnableCorsBehavior ecb = new EnableCorsBehavior();
m_webHost.Description.Behaviors.Add(ecb);
m_webHost.Open();
}
catch (CommunicationException ex)
{
Console.WriteLine("An exception occurred: {0}", ex.Message);
m_webHost.Abort();
return false;
}
return true;
}
示例11: Main
private static void Main(string[] args)
{
var address = new Uri("http://localhost:8000/FeedService/");
var svcHost = new WebServiceHost(typeof (FeedService), address);
try {
svcHost.Open();
Console.WriteLine("Service is running");
Console.WriteLine("Open browser at http://localhost:8000/FeedService/GetFeeds?format={atom/rss}");
Console.WriteLine("Press <ENTER> to quit...");
Console.ReadLine();
svcHost.Close();
}
catch (CommunicationException ce) {
Console.WriteLine("An exception occurred: {0}", ce.Message);
svcHost.Abort();
}
}