在两进程间设置一个为服务端,一个为客户端

服务端:

使用代码

            string baseAddress = @"http://localhost:8000/ServiceModelSamples11/service";           

    WSHttpBinding binding1 = new WSHttpBinding();

            binding1.CloseTimeout = new TimeSpan(0, 2, 0);

            serviceHost = new ServiceHost(typeof(CalculatorService));

            serviceHost.AddServiceEndpoint(typeof(ICalculator), binding1, baseAddress);

            serviceHost.Open();

客户端:

使用代码

    System.ServiceModel.Channels.Binding httpBinding = new BasicHttpBinding();

    ChannelFactory<IGeneralCalculator> factory = new ChannelFactory<IGeneralCalculator>(httpBinding);

    IGeneralCalculator proxy = factory.CreateChannel(new EndpointAddress("http://localhost/wcfservice/GeneralCalculatorService.svc"));

    double iRst = proxy.Add(100,100);

相关文章:

  • 2021-12-04
  • 2022-01-05
  • 2021-08-22
  • 2022-12-23
  • 2021-04-15
  • 2021-11-12
  • 2021-08-18
猜你喜欢
  • 2022-12-23
  • 2021-07-02
  • 2021-10-18
  • 2021-12-22
  • 2022-12-23
  • 2022-01-04
相关资源
相似解决方案