public async Task Run(string httpAddress, string listenToken) { using (var host = new WebServiceHost(this.GetType())) { var webHttpRelayBinding = new WebHttpRelayBinding(EndToEndWebHttpSecurityMode.Transport, RelayClientAuthenticationType.RelayAccessToken) {IsDynamic = false}; host.AddServiceEndpoint(this.GetType(), webHttpRelayBinding, httpAddress) .EndpointBehaviors.Add( new TransportClientEndpointBehavior( TokenProvider.CreateSharedAccessSignatureTokenProvider(listenToken))); host.Open(); Console.WriteLine("Copy the following address into a browser to see the image: "); Console.WriteLine(httpAddress + "/Image"); Console.WriteLine(); Console.WriteLine("Press [Enter] to exit"); Console.ReadLine(); host.Close(); } }
public async Task Run(string hostName, string listenToken) { string httpAddress = new UriBuilder("http", hostName, -1, "svc").ToString(); using (var host = new WebServiceHost(GetType())) { host.AddServiceEndpoint( GetType(), new WebHttpRelayBinding( EndToEndWebHttpSecurityMode.None, RelayClientAuthenticationType.None) {IsDynamic = true}, httpAddress) .EndpointBehaviors.Add( new TransportClientEndpointBehavior( TokenProvider.CreateSharedAccessSignatureTokenProvider(listenToken))); host.Open(); Console.WriteLine("Starting a browser to see the image: "); Console.WriteLine(httpAddress + "/Image"); Console.WriteLine(); // launching the browser System.Diagnostics.Process.Start(httpAddress + "/Image"); Console.WriteLine("Press [Enter] to exit"); Console.ReadLine(); host.Close(); } }
static void Main (string[] args) { LegoRestService DemoServices = new LegoRestService (); WebServiceHost _serviceHost = new WebServiceHost (DemoServices, new Uri ("http://localhost:8000/DEMOService")); _serviceHost.Open (); Console.ReadKey (); _serviceHost.Close (); }
static void Main(string[] args) { // Before running replace the servicebus namespace (next line) and REPLACESERVICEBUSKEY (app.config) string serviceNamespace = "jtarquino"; string serviceBusKey = "REPLACEKEYHERE"; Console.Write("Your Service Namespace: "); // Tranport level security is required for all *RelayBindings; hence, using https is required Uri address = ServiceBusEnvironment.CreateServiceUri("https", serviceNamespace, "Timer"); WebServiceHost host = new WebServiceHost(typeof(ProblemSolver), address); WebHttpRelayBinding binding = new WebHttpRelayBinding(EndToEndWebHttpSecurityMode.None, RelayClientAuthenticationType.None); host.AddServiceEndpoint( typeof(IProblemSolver), binding, address) .Behaviors.Add(new TransportClientEndpointBehavior { TokenProvider = TokenProvider.CreateSharedAccessSignatureTokenProvider("RootManageSharedAccessKey", serviceBusKey) }); host.Open(); Console.WriteLine(address + "CurrentTime"); Console.WriteLine("Press ENTER to close"); Console.ReadLine(); host.Close(); }
private static void Two() { Console.WriteLine("Starting service..."); // Configure the credentials through an endpoint behavior. TransportClientEndpointBehavior relayCredentials = new TransportClientEndpointBehavior(); relayCredentials.TokenProvider = TokenProvider.CreateSharedAccessSignatureTokenProvider("RootManageSharedAccessKey", "fBLL/4/+rEsCOiTQPNPS6DJQybykqE2HdVBsILrzMLY="); // Create the binding with default settings. WebHttpRelayBinding binding = new WebHttpRelayBinding(); binding.Security.RelayClientAuthenticationType = RelayClientAuthenticationType.None; // Get the service address. // Use the https scheme because by default the binding uses SSL for transport security. Uri address = ServiceBusEnvironment.CreateServiceUri("https", "johnsonwangnz", "Rest"); // Create the web service host. WebServiceHost host = new WebServiceHost(typeof(EchoRestService), address); // Add the service endpoint with the WS2007HttpRelayBinding. host.AddServiceEndpoint(typeof(IEchoRestContract), binding, address); // Add the credentials through the endpoint behavior. host.Description.Endpoints[0].Behaviors.Add(relayCredentials); // Start the service. host.Open(); Console.WriteLine("Listening..."); Console.ReadLine(); host.Close(); }
static void Main(string[] args) { WebServiceHost webServiceHost = new WebServiceHost(typeof(PartyService.Service)); WebHttpBinding serviceBinding = new WebHttpBinding(WebHttpSecurityMode.TransportCredentialOnly); serviceBinding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Basic; ServiceEndpoint ep = webServiceHost.AddServiceEndpoint( typeof(PartyService.IService), serviceBinding, "http://localhost:8000/service"); ep.Behaviors.Add(new PartyService.ProcessorBehaviour()); WebHttpBinding staticBinding = new WebHttpBinding(WebHttpSecurityMode.None); ServiceEndpoint sep = webServiceHost.AddServiceEndpoint( typeof(PartyService.IStaticItemService), new WebHttpBinding(), "http://localhost:8000"); webServiceHost.Credentials.UserNameAuthentication.UserNamePasswordValidationMode = UserNamePasswordValidationMode.Custom; webServiceHost.Credentials.UserNameAuthentication.CustomUserNamePasswordValidator = new PartyService.Validator(); webServiceHost.Description.Behaviors.Find<ServiceDebugBehavior>().IncludeExceptionDetailInFaults = true; webServiceHost.Open(); Console.WriteLine("Service is running - press enter to quit"); Console.ReadLine(); webServiceHost.Close(); Console.WriteLine("Service stopped"); }
static void Main(string[] args) { WebServiceHost host=new WebServiceHost(typeof(OperatingSystemService),new Uri("http://localhost:8013/RESTWebservice/")); host.Open(); Console.ReadKey(); host.Close(); }
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(); } }
static void Main(string[] args) { // var webServiceHost = new ServiceHost(typeof(Machine)); var webServiceHost = new WebServiceHost(typeof(Machine), new Uri("http://localhost:8080/RESTWcf")); webServiceHost.Open(); Console.ReadLine(); webServiceHost.Close(); }
static void Main(string[] args) { WebServiceHost wh = new WebServiceHost(typeof(HelloWorldService),new Uri(ServiceUri)); wh.Open(); Console.WriteLine("Service opened on {0}", ServiceUri); Console.WriteLine("Press any key to stop service..."); Console.ReadKey(); wh.Close(); }
public static void Main() { var host = new WebServiceHost(typeof(LicensewebService), new Uri("http://localhost:8000/")); var ep = host.AddServiceEndpoint(typeof(ILicensewebService), new WebHttpBinding(), ""); host.Open(); Console.WriteLine("Service running, press enter to quit"); Console.ReadLine(); host.Close(); }
private static void Main() { BindRequestToProcessors(); _service = new WebServiceHost(typeof(JsonServicePerCall)); _service.Open(); Console.WriteLine("Sample REST Service is running"); Console.WriteLine("Press any key to exit\n"); Console.ReadKey(); _service.Close(); }
static void Main(string[] args) { WebService DemoServices = new WebService(); WebHttpBinding binding = new WebHttpBinding(); WebServiceHost serviceHost = new WebServiceHost(DemoServices, new Uri("http://localhost:8000/")); serviceHost.AddServiceEndpoint(typeof(IWebService), binding, ""); serviceHost.Open(); Console.ReadKey(); serviceHost.Close(); }
private static void Main(string[] args) { var service = new WebServiceHost(typeof(JsonServicePerCall)); service.Open(); Console.WriteLine("Service is running"); Console.WriteLine("Press any key to exit\n"); Console.ReadLine(); service.Close(); }
static void Main(string[] args) { WebServiceHost host = new WebServiceHost(typeof(Service), new Uri("http://localhost:8200/")); ServiceEndpoint ep = host.AddServiceEndpoint(typeof(IService), new WebHttpBinding(), ""); host.Open(); Console.WriteLine("Service is running"); Console.WriteLine("Press enter to quit..."); Console.ReadLine(); host.Close(); }
static void Main(string[] args) { using (WebServiceHost serviceHost = new WebServiceHost(typeof(StorageClientService.StorageClientService))) { //serviceHost.AddServiceEndpoint(typeof(IStorageClientService), new WebHttpBinding(), ""); serviceHost.Open(); Console.WriteLine("Listening on port 23000..."); Console.WriteLine("Press Enter to continue..."); Console.ReadLine(); serviceHost.Close(); } }
static void Main(string[] args) { using (var serviceHost = new WebServiceHost(typeof(ExampleService))) { serviceHost.Open(); Console.WriteLine("WCF REST JSON service is running..."); Console.ReadLine(); serviceHost.Close(); } }
private static void Main() { ConfigureService(); _service = new WebServiceHost(typeof(JsonServicePerCall)); _service.Open(); Console.WriteLine("ShipTrackingService is running"); Console.WriteLine("Press any key to exit\n"); Console.ReadKey(); _service.Close(); }
static void Main(string[] args) { using (WebServiceHost host = new WebServiceHost(typeof(ScreenNailerService))) { host.Open(); Console.WriteLine("Press enter to stop"); Console.ReadLine(); host.Close(); } }
static void Main() { Uri baseAddress = new Uri("http://localhost:8000/RoomReservation"); var host = new WebServiceHost(typeof(RoomReservationService), baseAddress); host.Open(); Console.WriteLine("service running"); Console.WriteLine("Press return to exit..."); Console.ReadLine(); if (host.State == CommunicationState.Opened) host.Close(); }
static void Main(string[] args) { //TODO: Get uri from configuration var uri = "http://localhost:1234"; var host = new WebServiceHost(typeof (NancyWcfGenericService), new Uri(uri)); host.AddServiceEndpoint(typeof (NancyWcfGenericService), new WebHttpBinding(), ""); host.Open(); Console.ReadKey(); host.Close(); }
static void Main(string[] args) { // Per il funzionamento: lanciare da cmd autenticato come amministratore // mettendo nel parametro user l'utente loggato // netsh http add urlacl url=http://+:8000/ user=administrator WebServiceHost host = new WebServiceHost(typeof(ServiceEsposed.Service)); host.Open(); Console.WriteLine("Service running"); Console.WriteLine("Press ENTER to stop the service"); Console.ReadLine(); host.Close(); }
private static int Main(string[] args) { IGoServer server = new Oasis(); WebHttpBinding binding = new WebHttpBinding(); // TODO: Make this URI configurable. Uri uri = new Uri("http://localhost:8000/"); WebServiceHost _serviceHost = new WebServiceHost(server, uri); _serviceHost.AddServiceEndpoint(typeof(IGoServer), binding, "oasis"); _serviceHost.Open(); Console.ReadKey(); _serviceHost.Close(); return 0; }
public void ServiceDebugBehaviorTest () { var host = new WebServiceHost (typeof (MyService), new Uri ("http://localhost:8080/")); ServiceEndpoint webHttp = host.AddServiceEndpoint ("MonoTests.System.ServiceModel.Web.WebServiceHostTest+MyService", new WebHttpBinding (), "WebHttpBinding"); Assert.AreEqual (true, host.Description.Behaviors.Find<ServiceDebugBehavior> ().HttpHelpPageEnabled, "HttpHelpPageEnabled #1"); Assert.AreEqual (true, host.Description.Behaviors.Find<ServiceDebugBehavior> ().HttpsHelpPageEnabled, "HttpsHelpPageEnabled #1"); host.Open (); Assert.AreEqual (false, host.Description.Behaviors.Find<ServiceDebugBehavior> ().HttpHelpPageEnabled, "HttpHelpPageEnabled #2"); Assert.AreEqual (false, host.Description.Behaviors.Find<ServiceDebugBehavior> ().HttpsHelpPageEnabled, "HttpsHelpPageEnabled #2"); host.Close (); }
static void Main(string[] args) { #region wcf web http service WebServiceHost host = new WebServiceHost(typeof(RestService), new Uri("http://localhost:8080/")); ServiceEndpoint ep = host.AddServiceEndpoint(typeof(IRestService), new WebHttpBinding(), ""); ServiceDebugBehavior sdb = host.Description.Behaviors.Find<ServiceDebugBehavior>(); sdb.HttpHelpPageEnabled = false; host.Description.Endpoints[0].EndpointBehaviors.Add(new WebHttpBehavior { HelpEnabled=true}); //add IErrorHandler entension host.Description.Behaviors.Add(new MyServiceBehavior()); //add custom message inspector //host.Description.Endpoints[0].EndpointBehaviors.Add(new CustomEndpointBehavior()); //ContractDescription cd = host.Description.Endpoints[0].Contract; //OperationDescription myOperationDescription = cd.Operations.Find("CreateStudent"); //DataContractSerializerOperationBehavior serializerBehavior = myOperationDescription.Behaviors.Find<DataContractSerializerOperationBehavior>(); //if (serializerBehavior == null) //{ // serializerBehavior = new DataContractSerializerOperationBehavior(myOperationDescription); // myOperationDescription.Behaviors.Add(serializerBehavior); //} //serializerBehavior.DataContractResolver = new SharedTypeResolver(); host.Open(); //Console.WriteLine("Service is running"); //Console.WriteLine("Press enter to quit..."); //Console.ReadLine(); //host.Close(); #endregion #region wcf web http service and soap service ServiceHost sh = new ServiceHost(typeof(RestService),new Uri("http://localhost:8090/")); ServiceMetadataBehavior smb = new ServiceMetadataBehavior(); smb.HttpGetEnabled = true; smb.MetadataExporter.PolicyVersion = PolicyVersion.Policy15; sh.Description.Behaviors.Add(smb); sh.AddServiceEndpoint(typeof(IRestService),new BasicHttpBinding(),"soap"); ServiceEndpoint sep = sh.AddServiceEndpoint(typeof(IRestService), new WebHttpBinding(), "web"); sep.EndpointBehaviors.Add(new WebHttpBehavior()); sh.Open(); Console.WriteLine("Service is running"); Console.WriteLine("Press enter to quit..."); Console.ReadLine(); sh.Close(); host.Close(); #endregion }
public static void Main () { var host = new WebServiceHost (typeof (HogeService)); /* host.Description.Behaviors.Add ( new ServiceMetadataBehavior () { HttpGetEnabled = true, HttpGetUrl = new Uri ("http://localhost:8080/HogeService/wsdl") }); */ var binding = new WebHttpBinding (); host.AddServiceEndpoint (typeof (IHogeService), binding, "http://localhost:8080"); host.Open (); Console.WriteLine ("Type [CR] to close"); Console.ReadLine (); host.Close (); }
static void Main(string[] args) { WebServiceHost host = new WebServiceHost( typeof(ws.PropostaLibraryREST.PropostaServico)); host.Open(); Console.WriteLine("O hosting de serviço proposta está disponível em:"); foreach (ServiceEndpoint item in host.Description.Endpoints) { Console.WriteLine(item.Address.ToString()); } Console.ReadKey(); Console.WriteLine("Pressione <ENTER> para fechar a conexão"); host.Close(); }
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(); } }
public void WebHttpBehaviorTest1 () { var host = new WebServiceHost (typeof (MyService), new Uri ("http://localhost:8080/")); ServiceEndpoint webHttp = host.AddServiceEndpoint ("MonoTests.System.ServiceModel.Web.WebServiceHostTest+MyService", new WebHttpBinding (), "WebHttpBinding"); ServiceEndpoint basicHttp = host.AddServiceEndpoint ("MonoTests.System.ServiceModel.Web.WebServiceHostTest+MyService", new BasicHttpBinding (), "BasicHttpBinding"); Assert.AreEqual (0, webHttp.Behaviors.Count, "webHttp.Behaviors.Count #1"); Assert.AreEqual (0, basicHttp.Behaviors.Count, "basicHttp.Behaviors.Count #1"); host.Open (); Assert.AreEqual (1, webHttp.Behaviors.Count, "webHttp.Behaviors.Count #2"); Assert.AreEqual (typeof (WebHttpBehavior), webHttp.Behaviors [0].GetType (), "behavior type"); Assert.AreEqual (0, basicHttp.Behaviors.Count, "basicHttp.Behaviors.Count #2"); host.Close (); }
private static void createWebService() { using (WebServiceHost host = new WebServiceHost(typeof(AtuavWebServiceImp), Settings.BaseAddress)) { // Open the ServiceHost to start listening for messages. Since // no endpoints are explicitly configured, the runtime will create // one endpoint per base address for each service contract implemented // by the service. host.Open(); Console.WriteLine("The service is ready at {0}", Settings.BaseAddress); Console.WriteLine("Press <Enter> to stop the service."); Console.ReadLine(); // Close the ServiceHost. host.Close(); } }