2016-07-05 3 views
2

Как настроить wsHttpBinding с ядром .NET, Должен ли я настраиваться в файле Project.json? Перед .NET Ядра конфигурация, как показано нижеWCF .NET Core - Конфигурация WsHttpBinding project.json

<system.serviceModel> 
<bindings> 
    <wsHttpBinding> 
    <binding name="IService_Endpoint"> 
     <security mode="None" /> 
    </binding> 
    </wsHttpBinding> 
</bindings> 
<client> 
    <endpoint address="http://serviceURL/Service.svc" 
     binding="wsHttpBinding" bindingConfiguration="IService_Endpoint" 
     contract="IService" name="IService_Endpoint" /> 
</client> 

Я нашел статью, которая работает похоже, что я ищу, но его BasicHttpBinding, мне нужно WsHttpBinding.

ChannelFactory<IGetPeopleService> factory = null; 
IGetPeopleService serviceProxy = null; 
Binding binding = null; 

binding = new BasicHttpBinding(BasicHttpSecurityMode.None); 
factory = new ChannelFactory<IGetPeopleService>(binding, new EndpointAddress("http://localhost/people.svc")); 
serviceProxy = factory.CreateChannel(); 

var result = serviceProxy.GetPeopleData(100); 

ответ

2

Оно должно быть простым, как следующие:

ChannelFactory<IGetPeopleService> factory = null; 
IGetPeopleService serviceProxy = null; 
Binding binding = null; 

binding = new WsHttpBinding(SecurityMode.None); 
factory = new ChannelFactory<IGetPeopleService>(binding, new EndpointAddress("http://localhost/people.svc")); 
serviceProxy = factory.CreateChannel(); 

var result = serviceProxy.GetPeopleData(100); 

Baically, замещать BasicHttpBinding для WsHttpBinding.

ADDED Информация

Взятые из this answer:

Вы должны добавить ссылку на System.ServiceModel в вашем project.json, как это:

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

Примечание этот ответ был для ASP .NET 5 Pre-Release.

+0

Тим, спасибо за ваш ответ. Я не могу разрешить WsHtppBinding с той же сборкой SystemModel –

+0

@AnandPatel - Вы имеете в виду 'WsHttpBinding' или' WsHtppBinding'? Это должно быть «WsHttpBinding» в моем примере (два «t», а не два «p»). – Tim

+0

Извините за тип. yes WsHttpBinding –