Exemplo n.º 1
0
            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);
                }
            }
        /// <summary>
        /// Closes the specified service client.
        /// </summary>
        /// <param name="client">The service client to be closed.</param>
        private void _CloseChannel(IChannel client)
        {
            if (client == null)
            {
                return;
            }

            ServiceHelper.CloseCommObject(client);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Queries load-balancing service for routing service url.
        /// </summary>
        /// <returns>Result of the url request.</returns>
        /// <exception cref="ESRI.ArcLogistics.CommunicationException">An error
        /// occured during retrieval of the service url.
        /// </exception>
        private LoadBalanceResult _GetServiceUrl()
        {
            var result = default(LoadBalanceResult);

            _serviceWrapper.Invoke(() =>
            {
                var client = ServiceHelper.CreateServiceClient <LoadBalanceServiceSoapClient>(
                    "LoadBalanceServiceBinding",
                    _serviceUrl);

                try
                {
                    result = client.GetServiceUrl();
                }
                finally
                {
                    ServiceHelper.CloseCommObject(client);
                }
            });

            return(result);
        }
Exemplo n.º 4
0
        private void _CloseClient(TClient client)
        {
            int refCount = 0;

            IAsyncState asyncState = client as IAsyncState;

            if (asyncState != null)
            {
                refCount = asyncState.RefCount;
            }

            if (refCount == 0)
            {
                try
                {
                    this.OnCloseInnerClient(client);
                }
                catch { } // ignore errors

                ServiceHelper.CloseCommObject(client);
            }
        }