private void _InitTokenInfo(string serviceUrl, NetworkCredential credentials) { var client = ServiceHelper.CreateServiceClient <ServiceCatalogPortClient>( "CatalogServiceBinding", serviceUrl); // legal way to disable channel factory caching System.ServiceModel.ChannelFactory <ServiceCatalogPort> cf = client.ChannelFactory; try { // set credentials to SOAP client if needed if (_requiresHttpAuthentication && credentials != null) { ServiceHelper.SetClientCredentials(client, credentials); } // check if server requires token authentication if (client.RequiresTokens()) { _tokenServiceUrl = client.GetTokenServiceURL(); _requiresTokens = true; } else { _requiresTokens = false; } } finally { ServiceHelper.CloseCommObject(client); } }
private TClient _CreateClient() { TClient client = this.CreateInnerClient(_MakeServiceUrl()); // access channel factory: // this strange trick is a legal way to disable channel factory caching ChannelFactory <TChannel> fact = client.ChannelFactory; // set credentials if necessary if (_connection.RequiresHttpAuthentication) { ServiceHelper.SetClientCredentials(client, _connection.Credentials); } return(client); }