WCF .NET Core - WsHttpBinding Configuration project.json

后端 未结 1 1062
我寻月下人不归
我寻月下人不归 2021-01-18 16:53

How do I configure wsHttpBinding with .NET core, Should I configure in Project.json file ? Before .NET Core the configuration is like below



        
1条回答
  •  一整个雨季
    2021-01-18 17:30

    It should be as simple as the following:

    ChannelFactory factory = null;  
    IGetPeopleService serviceProxy = null;  
    Binding binding = null;
    
    binding = new WsHttpBinding(SecurityMode.None);  
    factory = new ChannelFactory(binding, new EndpointAddress("http://localhost/people.svc"));  
    serviceProxy = factory.CreateChannel();
    
    var result = serviceProxy.GetPeopleData(100);
    

    Baically, swap BasicHttpBinding for WsHttpBinding.

    ADDED Information

    Taken from this answer:

    You need to add a reference to System.ServiceModel in your project.json, like this:

    {
      "commands": {
          "run": "run"
      },
      "frameworks": {
          "dnx451": {
              "dependencies": {
                  "Microsoft.AspNet.Mvc": "6.0.0-beta2"
              },
              "frameworkAssemblies": {
                  "System.ServiceModel": "4.0.0.0"
              }
          }
      }
    }
    

    Note this answer was for ASP.NET 5 Pre-Release.

    0 讨论(0)
提交回复
热议问题