question

Upvotes
Accepted
488 15 17 28

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 512.0 KiB each and 1.0 MiB total.

1 Answer

Upvotes
Accepted
401 18 20 34

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 512.0 KiB each and 1.0 MiB total.