How do I configure wsHttpBinding with .NET core, Should I configure in Project.json file ? Before .NET Core the configuration is like below
<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>
I found an article which works looks like I am looking for but its BasicHttpBinding, I need 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);
It should be as simple as the following:
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, 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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With