Esempio n. 1
0
        /// <summary>
        /// Implementation of the lookup method from the IUddiLookupClient interface
        /// </summary>
        /// <param name="parameters">The parameters used to make a lookup</param>
        /// <returns></returns>
        public List <UddiLookupResponse> Lookup(LookupParameters parameters)
        {
            List <UddiLookupResponse> result;
            UddiLookupClientFactory   uddiLookupClientFactory = new UddiLookupClientFactory();
            Exception exception = null;

            foreach (Uri uri in _fallbackList)
            {
                try
                {
                    IUddiLookupClient client = uddiLookupClientFactory.CreateUddiLookupClient(uri);
                    result = client.Lookup(parameters);
                    return(result);
                }
                catch (Exception e)
                {
                    exception = e;
                    continue;
                }
            }

            //The fallbacklist was empty we return an empty list as result.
            if (exception == null)
            {
                return(new List <UddiLookupResponse>());
            }

            // We never got a valid result, so the last known exception is thrown
            throw exception;
        }
Esempio n. 2
0
        /// <summary>
        /// Creates an IUddiLookup implementation, as set in config.
        /// </summary>
        /// <returns>The IUddiLookup implementation</returns>
        public IUddiLookupClient CreateUddiLookupClient()
        {
            // 1. Get factory config:
            _config = ConfigurationHandler.GetConfigurationSection <RegistryLookupClientFactoryConfig>();

            // 2. Get the type to load:
            if (_config.ImplementationNamespaceClass == null || _config.ImplementationNamespaceClass == "")
            {
                throw new UddiNoImplementingClassException();
            }
            if (_config.ImplementationAssembly == null || _config.ImplementationAssembly == "")
            {
                throw new UddiNoImplementingAssemblyException();
            }
            string qualifiedTypename = _config.ImplementationNamespaceClass + ", " + _config.ImplementationAssembly;

            Type lookupClientType = Type.GetType(qualifiedTypename);

            if (lookupClientType == null)
            {
                throw new CouldNotLoadTypeException(qualifiedTypename);
            }

            // 3. Instantiate the type:
            IUddiLookupClient lookupClient = (IUddiLookupClient)lookupClientType.GetConstructor(new Type[0]).Invoke(null);

            return(lookupClient);
        }
Esempio n. 3
0
        public void LookingUpWhatProfilesAnIdentifierCanSupport()
        {
            var identifier        = new Identifier(TestConstants.EAN, TestConstants.TESTEAN);
            var orderService      = new UddiGuidId("uddi:b138dc71-d301-42d1-8c2e-2c3a26faf56a", true);
            var acceptedProtocols = new List <EndpointAddressTypeCode>();

            acceptedProtocols.Add(EndpointAddressTypeCode.http);
            var profileRoleIds = new List <UddiId>();

            profileRoleIds.Add(new UddiGuidId("uddi:88fbd6d5-6a25-4c08-91cc-5344c73c4d69", true));
            RegistryLookupClientFactory rlcf             = new RegistryLookupClientFactory();
            IUddiLookupClient           ulc              = rlcf.CreateUddiLookupClient();
            LookupParameters            lookupParameters = new LookupParameters(identifier, orderService, profileRoleIds, acceptedProtocols);

            List <UddiLookupResponse> results = ulc.Lookup(lookupParameters);

            Assert.IsNotNull(results);
            Assert.AreEqual(1, results.Count);
            //There is still support for getting the process roles like the Process
            //Assert.IsNotNull(results[0].Process);
            Assert.IsNotNull(results[0].ProcessRoles);
            //There is still support for getting the process roles via. the Process
            HashSet <string> names = new HashSet <string>();
            HashSet <string> processDefinitionIds = new HashSet <string>();

            foreach (var processRoleDefinition in results[0].ProcessRoles)
            {
                names.Add(processRoleDefinition.Name);
                processDefinitionIds.Add(processRoleDefinition.ProcessDefinitionId.ID);
            }
            Assert.IsTrue(names.Contains("Procurement-OrdAdv-BilSim-1.0 SellerParty"));
            // The id of the process definition
            Assert.IsTrue(processDefinitionIds.Contains("uddi:88fbd6d5-6a25-4c08-91cc-5344c73c4d69"));
        }
Esempio n. 4
0
        /// <summary>
        /// Creates an IUddiLookup implementation, as set in config.
        /// </summary>
        /// <returns>The IUddiLookup implementation</returns>
        public IUddiLookupClient CreateUddiLookupClient(Uri address)
        {
            // 1. Get factory config:
            _config = ConfigurationHandler.GetConfigurationSection <UddiLookupClientFactoryConfig>();

            // 2. Get the type to load:
            if (string.IsNullOrEmpty(_config.ImplementationNamespaceClass))
            {
                throw new UddiNoImplementingClassException();
            }

            if (string.IsNullOrEmpty(_config.ImplementationAssembly))
            {
                throw new UddiNoImplementingAssemblyException();
            }

            string qualifiedTypename = _config.ImplementationNamespaceClass + ", " + _config.ImplementationAssembly;

            Type lookupClientType = Type.GetType(qualifiedTypename);

            if (lookupClientType == null)
            {
                throw new CouldNotLoadTypeException(qualifiedTypename);
            }

            // 3. Instantiate the type:
            object[]          parameters      = new object[] { address };
            Type[]            typeArray       = new Type[] { typeof(Uri) };
            ConstructorInfo   constructorInfo = lookupClientType.GetConstructor(typeArray);
            IUddiLookupClient lookupClient    = (IUddiLookupClient)constructorInfo.Invoke(parameters);

            return(lookupClient);
        }
Esempio n. 5
0
        /// <summary>
        /// Performs a lookup in the UDDI and validates the response.
        /// </summary>
        /// <returns>Returns the UDDI response</returns>
        protected UddiLookupResponse PerformUddiLookup(LookupParameters uddiLookupParameters)
        {
            RegistryLookupClientFactory uddiClientFactory = new RegistryLookupClientFactory();
            IUddiLookupClient           uddiClient        = uddiClientFactory.CreateUddiLookupClient();
            List <UddiLookupResponse>   uddiResponses     = uddiClient.Lookup(uddiLookupParameters);

            Assert.AreEqual(1, uddiResponses.Count, "Unexcpected number of uddi results.");
            UddiLookupResponse selectedUddiResponse = uddiResponses[0];

            return(selectedUddiResponse);
        }
Esempio n. 6
0
        public void GetProcessDefinitions()
        {
            List <UddiId> uddiIds = new List <UddiId>();

            uddiIds.Add(new UddiStringId("uddi:AEE8B6DE-298F-4cbc-A96D-9AE8AED0AC31", true));
            uddiIds.Add(new UddiStringId("uddi:c001daa0-8ba3-11dd-894e-770465b08940", true));

            RegistryLookupClientFactory rlcf = new RegistryLookupClientFactory();
            IUddiLookupClient           ulc  = rlcf.CreateUddiLookupClient();

            List <ProcessDefinition> processes = ulc.GetProcessDefinitions(uddiIds);

            Assert.AreEqual(uddiIds.Count, processes.Count);
        }
Esempio n. 7
0
        static UddiLookupResponse Uddi(OiosiMessage message, DocumentTypeConfig docTypeConfig)
        {
            UddiConfig uddiConfig = ConfigurationHandler.GetConfigurationSection <UddiConfig>();

            Console.WriteLine("1. UDDI services");

            Console.ForegroundColor = ConsoleColor.Gray;
            Console.WriteLine(" Using UDDI/NemHandel register(s):");
            foreach (Registry registry in uddiConfig.LookupRegistryFallbackConfig.PrioritizedRegistryList)
            {
                foreach (string endpoint in registry.Endpoints)
                {
                    Console.WriteLine("  " + endpoint);
                }
            }

            // Create a uddi client
            RegistryLookupClientFactory uddiClientFactory = new RegistryLookupClientFactory();

            uddiClient = uddiClientFactory.CreateUddiLookupClient();

            // Get the UDDI parameters with which to call the UDDI server
            LookupParameters parameters = GetUddiParameters(message, docTypeConfig);

            Console.WriteLine(" Lookup Parameters");
            Console.WriteLine("  EndPoint      : " + parameters.Identifier.ToString());
            Console.WriteLine("  EndPoint type : " + parameters.Identifier.KeyTypeCode);
            Console.WriteLine("  Profile       : " + GetProfileName(message, docTypeConfig));

            // Perform the actual UDDI lookup
            UddiLookupResponse uddiResponse = PerformUddiLookup(parameters);

            Console.WriteLine();
            Console.ForegroundColor = ConsoleColor.White;
            Console.WriteLine(" Got UDDI reply:");
            Console.ForegroundColor = ConsoleColor.Yellow;

            if (uddiResponse == null)
            {
                Console.WriteLine("  The endpoint is no registrated in UDDI!");
            }
            else
            {
                Console.WriteLine("  " + uddiResponse.EndpointAddress.GetKeyAsString());
            }
            Console.ForegroundColor = ConsoleColor.White;

            return(uddiResponse);
        }
Esempio n. 8
0
        //static IUddiLookupClient uddiClient;


        private UddiLookupResponse Uddi(OiosiMessage message, DocumentTypeConfig docTypeConfig)
        {
            // Create a uddi client
            RegistryLookupClientFactory uddiClientFactory = new RegistryLookupClientFactory();
            IUddiLookupClient           uddiClient        = uddiClientFactory.CreateUddiLookupClient();

            // Get the UDDI parameters with which to call the UDDI server
            LookupParameters parameters = this.GetUddiParameters(message, docTypeConfig);

            // Perform the actual UDDI lookup
            UddiLookupResponse uddiResponse = this.PerformUddiLookup(parameters, uddiClient);

            // Print out info
            Console.Write("\n  1. Got UDDI reply\n       ");
            Console.ForegroundColor = ConsoleColor.Yellow;
            Console.WriteLine(uddiResponse.EndpointAddress.GetKeyAsString());
            Console.ForegroundColor = ConsoleColor.White;

            return(uddiResponse);
        }
Esempio n. 9
0
        private UddiLookupResponse PerformUddiLookup(LookupParameters uddiLookupParameters, IUddiLookupClient uddiClient)
        {
            UddiLookupResponse selectedUddiResponse = null;

            // Do the actual UDDI call
            List <UddiLookupResponse> uddiResponses = uddiClient.Lookup(uddiLookupParameters);

            // Pick the first response gotten
            if (uddiResponses.Count == 0)
            {
                // No endpoint found in the uddi(s).
                throw new Exception("Endpoint does not exixt. " + uddiLookupParameters.Identifier.KeyTypeCode.ToString() + ": " + uddiLookupParameters.Identifier + ". ");
            }
            else if (uddiResponses.Count == 1)
            {
                selectedUddiResponse = uddiResponses[0];
                // Make sure the UDDI call returned the reference to a certificate and an endpoint address
                if (selectedUddiResponse.CertificateSubjectSerialNumber == null)
                {
                    throw new Exception("The UDDI call didn't return a certificate serial number");
                }
                if (selectedUddiResponse.EndpointAddress == null)
                {
                    throw new Exception("The UDDI call didn't return any endpoint");
                }
            }
            else
            {
                // more the one - not good
                Console.WriteLine("To many endpoints found (" + uddiResponses.Count + "), for " + uddiLookupParameters.Identifier.KeyTypeCode.ToString() + ": " + uddiLookupParameters.Identifier + ". Using the first one.");
                selectedUddiResponse = uddiResponses[0];
                // Make sure the UDDI call returned the reference to a certificate and an endpoint address
                if (selectedUddiResponse.CertificateSubjectSerialNumber == null)
                {
                    throw new Exception("The UDDI call didn't return a certificate serial number");
                }
                if (selectedUddiResponse.EndpointAddress == null)
                {
                    throw new Exception("The UDDI call didn't return any endpoint");
                }
            }

            return(selectedUddiResponse);
        }