Exemplo n.º 1
0
    static void Main(string[] args)
    {
        Uri uri = new Uri("http://localhost:1100");
        BasicHttpBinding binding = new BasicHttpBinding();

        using (ServiceHost sh = new ServiceHost(typeof(MyService), uri))
        {
            ServiceEndpoint         se = sh.AddServiceEndpoint(typeof(IService), binding, "");
            ServiceMetadataBehavior smb;
            smb = sh.Description.Behaviors.Find <ServiceMetadataBehavior>();
            if (smb == null)
            {
                smb = new ServiceMetadataBehavior();
                smb.HttpGetEnabled = true;
                smb.HttpGetUrl     = new Uri("http://localhost:1100/mex");
                sh.Description.Behaviors.Add(smb);
            }
            MyEndpointBehavior bhv = new MyEndpointBehavior();
            se.EndpointBehaviors.Add(bhv);


            sh.Open();
            Console.WriteLine("service is ready");
            Console.ReadKey();
            sh.Close();
        }
    }
Exemplo n.º 2
0
        public static void Main()
        {
            using (var client = new MyWcfClient())
            {
                var myEndpointBehavior = new MyEndpointBehavior();

                client.Endpoint.Behaviors.Add(myEndpointBehavior);

                // TODO: your things with the client.
            }
        }