• wcf-学习


    将服务寄宿与控制台:

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.ServiceModel;
    using System.ServiceModel.Description;
    using System.Text;
    using System.Threading.Tasks;
    using MyWcfService;
    
    namespace Host
    {
        class Program
        {
            static void Main(string[] args)
            {
                using (ServiceHost host = new ServiceHost(typeof(Service1)))
                {
    
                    host.AddServiceEndpoint(typeof(IService1), new WSHttpBinding(),
     "http://127.0.0.1:8733/Service1");
                    if (host.Description.Behaviors.Find<ServiceMetadataBehavior>() == null)
                    {
    
                        ServiceMetadataBehavior behavior = new ServiceMetadataBehavior();
                        behavior.HttpGetEnabled = true;
                        behavior.HttpGetUrl = new Uri("http://127.0.0.1:8733/Service1/metadata");
                        host.Description.Behaviors.Add(behavior);
    
                    }
    
                    host.Opened += delegate
    
                    {
                        Console.WriteLine("BookService,按任意键终止服务!");
                    };
    
                    host.Open();
                    Console.Read();
    
                }
            }
        }
    }

    客户端

    1.添加服务引用

     2.

     private void button1_Click(object sender, EventArgs e)
            {
                Service1Client service1Client = new Service1Client();
                MessageBox.Show(service1Client.GetData(2));
            }
  • 相关阅读:
    [MAC]如何抹掉 Mac 磁盘
    [MAC]出售、赠送或折抵 Mac 前该怎么做
    转载 软件项目计划如何编写举例
    GIT
    AWR实战分析之----direct path read temp
    ASM 磁盘组的的scrip
    巨杉db
    High waits on control file sequential read
    如何减小SQL 的物理读,。
    block size大小
  • 原文地址:https://www.cnblogs.com/dangnianxiaoqingxin/p/14616069.html
Copyright © 2020-2023  润新知