2016-07-05 8 views
2

Wie konfiguriere ich wsHttpBinding mit .NET Core, sollte ich in Project.json Datei konfigurieren? Vor .NET Core ist die Konfiguration wie unterWCF .NET Core - WsHttpBinding Konfiguration 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> 

ich einen Artikel gefunden, die für Suche sieht aus wie ich arbeitet, aber sein Basichttpbinding, ich brauche 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); 

Antwort

2

Es sollte so einfach wie die folgenden sein:

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 für WsHttpBinding tauschen.

Hinzugefügte Informationen

Entnommen this answer:

Sie müssen einen Verweis auf System.ServiceModel in Ihrem project.json hinzuzufügen, wie folgt aus:

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

Hinweis diese Antwort für ASP war .NET 5 Vorabversion.

+0

Tim, Danke für Ihre Antwort. Ich bin nicht in der Lage, WsHtppBinding mit in der gleichen SystemModel Assembly zu lösen –

+0

@AnandPatel - Meinst du 'WsHttpBinding' oder' WsHtppBinding'? Es sollte 'WsHttpBinding' für mein Beispiel sein (zwei" t ", nicht zwei" p "). – Tim

+0

Entschuldigung für Typ. ja WsHttpBinding –

Verwandte Themen