c# - Set behavior from config? -


i have wcf client & service solution creates client channel :

for(int = 0; < clientsection.endpoints.count; i++)         {             if(clientsection.endpoints[i].name == endpointconfigurationname)             {                 var endpointaddress = new endpointaddress(clientsection.endpoints[i].address.tostring());                 var nethttpbinding = new nethttpbinding(clientsection.endpoints[i].bindingconfiguration);                 var serviceendpoint = new serviceendpoint(contractdescription.getcontract(typeof(t)), nethttpbinding, endpointaddress);                  var channelfactory = new channelfactory<t>(serviceendpoint);                  break;             }         } 

this works fine need set behaviors well. in config file endpoint have behaviorconfiguration attribute, needs set above, how done?

add behavior channelfactory (client) object:

channelfactory.endpoint.endpointbehaviors.add(new webhttpbehavior()); 

and add the servcehost (server) object:

   servicehost.endpoint.endpointbehaviors.add(new servicemetadatabehavior()); 

you can read more here: msdn


Comments

Popular posts from this blog

asynchronous - C# WinSCP .NET assembly: How to upload multiple files asynchronously -

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -