question

Upvotes
Accepted
488 12 13 27

Inline WSHttpBinding configuration

Is it possible to configure web service bindings for web-service client objects directly from the source code (aside from config file)?

rkd-apirkdweb
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 5.0 MiB each and 10.0 MiB total.

1 Answer

Upvotes
Accepted
401 15 18 33

Yes. It is possible to configure web-service bindings for web-service client objects not only with the help of a configuration file but also directly in the source code.

Here is an example of a WSHttpBinding configuration for the Token Management service:

WSHttpBinding binding = new WSHttpBinding();

binding.Security.Mode = SecurityMode.Transport;

binding.SendTimeout = TimeSpan.FromMinutes( 1 );

binding.OpenTimeout = TimeSpan.FromMinutes( 1 );

binding.CloseTimeout = TimeSpan.FromMinutes( 1 );

binding.ReceiveTimeout = TimeSpan.FromMinutes( 10 );

binding.AllowCookies = false;

binding.HostNameComparisonMode = HostNameComparisonMode.StrongWildcard;

binding.MessageEncoding = WSMessageEncoding.Text;

binding.TextEncoding = System.Text.Encoding.UTF8;

TokenManagement_1Client client =

new TokenManagement_1Client(binding, new EndpointAddress("https://api.rkd.reuters.com/api/TokenManagement/TokenManagement.svc/Anonymous"));

And if you need to set up a proxy server for your application you can do this by adding corresponding lines to the binding object:

binding.ProxyAddress = new Uri("http://proxyhost.com:8080");

binding.UseDefaultWebProxy = false;

binding.BypassProxyOnLocal = false;

icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 5.0 MiB each and 10.0 MiB total.

Click below to post an Idea Post Idea