I am using custom binding in the sevrice side in C#. I want binary Encoding in HTTP.
<bindings>
<customBinding>
<binding name="myOwnBinding">
<binaryMessageEncoding></binaryMessageEncoding>
<httpTransport/>
</binding>
</customBinding>
</bindings>
<extensions>
<bindingExtensions>
<add name="myOwnBinding" type="CustomBinding.UserBinding,CustomBinding"/>
</bindingExtensions>
</extensions>
<service name="CustomBinding.Service1" behaviorConfiguration="CustomBinding.Service1Behavior">
This service is not going to expose the metadat开发者_StackOverflowa.So,i will not be able to create a service Reference in client to consume the servvice.
Now,I want to know how to use this binding in the client channel factory to consume this service.Below is my client side code.
EndpointAddress address = new EndpointAddress("http://localhost:2418/Service1.svc");
ChannelFactory<IService1> c = new ChannelFactory<IService1>(Binding, address);
IService1 reqChannel = c.CreateChannel();
String str = reqChannel.GetData(1);
How to manually fill the binding object that the Channel factory is expecting when service is developed with custom binding.?
Thanks Arun
I have sorted it out when i used the app.config to load the custom binding object.
System.ServiceModel.Channels.CustomBinding cus = new System.ServiceModel.Channels.CustomBinding("CustomBinding_IService1");
EndpointAddress address = new EndpointAddress("http://localhost:2418/Service1.svc");
ChannelFactory<IService1> c = new ChannelFactory<IService1>(cus);
IService1 serviceInstance = c.CreateChannel(address);
String str = serviceInstance.GetData(1);
Thanks
精彩评论