2016-07-05 9 views
2

.NETコアでwsHttpBindingを構成するにはどうすればいいですか?Project.jsonファイルで構成する必要がありますか? .NETのコアは、構成がWCF .NETコア - 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、WsHttpBindingためのスワップBasicHttpBinding

あなたはこのように、あなたのproject.jsonにSystem.ServiceModelへの参照を追加する必要があります:

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

(注)この答えはASPのためだったthis answerから撮影

情報を追加しました

.NET 5プレリリース

+0

Tim、ありがとうございます。同じSystemModelアセンブリでWsHtppBindingを解決できません。 –

+0

@AnandPatel - あなたは 'WsHttpBinding'または' WsHtppBinding'を意味しますか?私の例(2つの "t"ではなく2つの "p")ごとに 'WsHttpBinding'でなければなりません。 – Tim

+0

申し訳ありません。はいWsHttpBinding –

関連する問題