Facebook
From Sludgy Zebra, 6 Years ago, written in Plain Text.
This paste is a reply to Untitled from Sloppy Owl - view diff
Embed
Download Paste or View Raw
Hits: 358
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.ServiceModel;
  5. using System.ServiceModel.Description;
  6. using System.Text;
  7. using System.Threading.Tasks;
  8. using WCFServiceContract;
  9.  
  10. namespace WCFServiceHost
  11. {
  12.     class Program
  13.     {
  14.         static void Main(string[] args)
  15.         {
  16.             Uri baseAddress2 = new Uri("http://localhost:11112/DunnoWhat");
  17.             String baseAddress3 = "net.tcp://localhost:11113/SerwisTCP";
  18.             ServiceHost host = new ServiceHost(typeof(MojKalkulatorLZ));
  19.  
  20.             //ServiceEndpoint endpoint1 = host.Description.Endpoints.Find(typeof(IKalkulatorLZ));
  21.             ServiceEndpoint endpoint2 = host.AddServiceEndpoint(typeof(IKalkulatorLZ), new WSHttpBinding(), baseAddress2);
  22.             ServiceEndpoint endpoint3 = host.AddServiceEndpoint(typeof(IKalkulatorLZ), new NetTcpBinding(), baseAddress3);
  23.  
  24.             ServiceMetadataBehavior smb = new ServiceMetadataBehavior();
  25.             smb.HttpGetEnabled = true;
  26.             host.Description.Behaviors.Add(smb);
  27.  
  28.             host.Open();
  29.             Console.WriteLine("Host uruchomiony.");
  30.             Console.WriteLine("Aby zakonczyc nacisnij <ENTER>");
  31.             Console.ReadLine();
  32.             host.Close();
  33.  
  34.         }
  35.     }
  36. }
  37.