Exemple #1
0
        /// <summary>
        /// Static method to obtain instance of the ServiceCatalogService
        /// </summary>
        /// <param name="binding">The binding that defines the how the. Currently 2 pre-defined bindings are provided
        /// UsernameTokenOverSslBinding and UsernameTokenBinding. The binding used must match the OWSM policy defined on the service</param>
        /// <param name="endpointAddress">The URL of the endpoint that hosts the service</param>
        /// <param name="credentials">The credentials to be used to invoke the service</param>
        /// <returns>Instance of the ServiceCatalogService client</returns>
        public static ServiceCatalogServiceClient GetServiceCatalogServiceClient(System.ServiceModel.Channels.Binding binding, EndpointAddress endpointAddress, NetworkCredential credentials)
        {
            ServiceCatalogServiceClient client = new ServiceCatalogServiceClient(binding, endpointAddress);

            client.ClientCredentials.UserName.UserName = credentials.UserName;
            client.ClientCredentials.UserName.Password = credentials.Password;
            client.Endpoint.Behaviors.Add(new EmptyElementBehavior());
            return(client);
        }
        /// <summary>
        /// Tests a call to Service Catalog Service
        /// </summary>
        static void TestServiceCatalogService()
        {
            Console.WriteLine("TestServiceCatalogService");
            System.ServiceModel.Channels.Binding binding = FaBindingFactory.GetUsernameTokenBinding();
            EndpointAddress             endpointAddress  = new EndpointAddress(new Uri("Url to the service"));
            ServiceCatalogServiceClient client           = FaServiceFactory.GetServiceCatalogServiceClient(binding, endpointAddress, new NetworkCredential(userName, password));

            CatalogService[] result = client.getAllServiceEndPoints();
            if (null != result && result.Length > 0)
            {
                Console.WriteLine("  result.Length = " + result.Length);
            }
            else
            {
                if (null == result)
                {
                    Console.WriteLine("  result null ");
                }
                else
                {
                    Console.WriteLine("  result empty ");
                }
            }
        }
 /// <summary>
 /// Static method to obtain instance of the ServiceCatalogService
 /// </summary>
 /// <param name="binding">The binding that defines the how the. Currently 2 pre-defined bindings are provided 
 /// UsernameTokenOverSslBinding and UsernameTokenBinding. The binding used must match the OWSM policy defined on the service</param>
 /// <param name="endpointAddress">The URL of the endpoint that hosts the service</param>
 /// <param name="credentials">The credentials to be used to invoke the service</param>
 /// <returns>Instance of the ServiceCatalogService client</returns>
 public static ServiceCatalogServiceClient GetServiceCatalogServiceClient(System.ServiceModel.Channels.Binding binding, EndpointAddress endpointAddress, NetworkCredential credentials)
 {
     ServiceCatalogServiceClient client = new ServiceCatalogServiceClient(binding, endpointAddress);
     client.ClientCredentials.UserName.UserName = credentials.UserName;
     client.ClientCredentials.UserName.Password = credentials.Password;
     client.Endpoint.Behaviors.Add(new EmptyElementBehavior());
     return client;
 }