Advertisement
Guest User

Untitled

a guest
Dec 12th, 2019
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.29 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.ServiceModel;
  5. using System.ServiceModel.Description;
  6. using WcfServiceContract;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9.  
  10. namespace WCFserviceHost
  11. {
  12.     class Program
  13.     {
  14.         static void Main(string[] args)
  15.         {
  16.             Uri baseAddress = new Uri("http://localhost:10009/Matuszczyk");
  17.             ServiceHost mojHost = new ServiceHost(typeof(srv107), baseAddress);
  18.             try
  19.             {
  20.                 WSHttpBinding mojBanding = new WSHttpBinding();
  21.                 mojHost.AddServiceEndpoint(typeof(Isrv107), mojBanding, "Isrv107");
  22.                 ServiceMetadataBehavior smb = new ServiceMetadataBehavior();
  23.                 smb.HttpGetEnabled = true;
  24.                 mojHost.Description.Behaviors.Add(smb);
  25.  
  26.                 mojHost.Open();
  27.                 Console.WriteLine("Serwis jest uruchomiony.");
  28.                 Console.WriteLine("Nacisnij <ENTER> aby zakonczyc");
  29.                 Console.WriteLine();
  30.                 mojHost.Close();
  31.             }
  32.             catch (CommunicationException ce)
  33.             {
  34.                 Console.WriteLine("Wystapiol wyjatek: {0}", ce.Message);
  35.                 mojHost.Abort();
  36.             }
  37.         }
  38.        
  39.     }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement