Пример #1
0
        /**
         * Constructs the bindingKey based on the bindingKeyFormat specified in the properties. When no
         * bindingKeyFormat is specific the default format of uddi:${keyDomain}:${nodeName}-${serviceName}-{portName} is used.
         *
         * @param properties
         * @param serviceName
         * @param portName
         * @return the bindingKey
         */

        public static String getBindingKey(Properties properties, QName serviceName, String portName, Uri bindingUrl)
        {
            Properties tempProperties = new Properties();

            tempProperties.putAll(properties);
            tempProperties.put("serviceName", serviceName.getLocalPart());
            tempProperties.put("portName", portName);
            int port = bindingUrl.Port;

            if (port < 0)
            {
                if ("http".Equals(bindingUrl.Scheme, StringComparison.CurrentCultureIgnoreCase))
                {
                    port = 80;
                }
                else if ("https".Equals(bindingUrl.Scheme))
                {
                    port = 443;
                }
            }
            if (!tempProperties.containsKey("serverPort"))
            {
                tempProperties.put("serverPort", port.ToString());
            }

            //Constructing the binding Key
            String keyFormat  = properties.getProperty(Property.BINDING_KEY_FORMAT, DEFAULT_BINDING_KEY_FORMAT);
            String bindingKey = TokenResolver.replaceTokens(keyFormat, tempProperties).ToLower();

            return(bindingKey);
        }
Пример #2
0
        /**
         * Constructs the bindingKey based on the bindingKeyFormat specified in the properties. When no
         * bindingKeyFormat is specific the default format of uddi:${keyDomain}:${nodeName}-${serviceName}-{portName} is used.
         *
         * @param properties
         * @param serviceName
         * @param portName
         * @return the bindingKey
        */
        public static String getBindingKey(Properties properties, QName serviceName, String portName, Uri bindingUrl)
        {
            Properties tempProperties = new Properties();
            tempProperties.putAll(properties);
            tempProperties.put("serviceName", serviceName.getLocalPart());
            tempProperties.put("portName", portName);
            int port = bindingUrl.Port;
            if (port < 0)
            {
                if ("http".Equals(bindingUrl.Scheme, StringComparison.CurrentCultureIgnoreCase))
                {
                    port = 80;
                }
                else if ("https".Equals(bindingUrl.Scheme))
                {
                    port = 443;
                }
            }
            if (!tempProperties.containsKey("serverPort"))
                tempProperties.put("serverPort", port.ToString());

            //Constructing the binding Key
            String keyFormat = properties.getProperty(Property.BINDING_KEY_FORMAT, DEFAULT_BINDING_KEY_FORMAT);
            String bindingKey = TokenResolver.replaceTokens(keyFormat, tempProperties).ToLower();
            return bindingKey;
        }
Пример #3
0
        /// <summary>
        /// Constructs the serviceKey based on the serviceKeyFormat specified in the properties. When no
        ///serviceKeyFormat is specific the default format of uddi:${keyDomain}:${serviceName} is used.
        /// </summary>
        /// <param name="properties"></param>
        /// <param name="serviceName"></param>
        /// <returns></returns>
        public static String getServiceKey(Properties properties, String serviceName)
        {
            Properties tempProperties = new Properties();

            tempProperties.putAll(properties);
            tempProperties.put("serviceName", serviceName);
            //Constructing the serviceKey
            String keyFormat  = tempProperties.getProperty(Property.SERVICE_KEY_FORMAT, DEFAULT_SERVICE_KEY_FORMAT);
            String serviceKey = TokenResolver.replaceTokens(keyFormat, tempProperties).ToLower();

            return(serviceKey);
        }
Пример #4
0
        public static void main(string[] args)
        {
            UDDIClient clerkManager = null;
            Transport transport = null;
            UDDIClerk clerk = null;
            try
            {
                clerkManager = new UDDIClient("uddi.xml");

                transport = clerkManager.getTransport("default_non_root");

                UDDI_Security_SoapBinding security = transport.getUDDISecurityService();
                UDDI_Inquiry_SoapBinding inquiry = transport.getUDDIInquiryService();
                UDDI_Publication_SoapBinding publish = transport.getUDDIPublishService();

                clerk = clerkManager.getClerk("default_non_root");

                //Wadl Import example

                application app = WADL2UDDI.ParseWadl("..\\..\\..\\juddi-client.net.test\\resources\\sample.wadl");
                List<Uri> urls = WADL2UDDI.GetBaseAddresses(app);
                Uri url = urls[0];
                String domain = url.Host;

                tModel keygen = UDDIClerk.createKeyGenator("uddi:" + domain + ":keygenerator", domain, "en");
                //save the keygen
                save_tModel stm = new save_tModel();
                stm.authInfo = clerk.getAuthToken(clerk.getUDDINode().getSecurityUrl());
                stm.tModel = new tModel[] { keygen };

                publish.save_tModel(stm);
                Properties properties = new Properties();

                properties.put("keyDomain", domain);
                properties.put("businessName", domain);
                properties.put("serverName", url.Host);
                properties.put("serverPort", url.Port.ToString());
                //wsdlURL = wsdlDefinition.getDocumentBaseURI();
                WADL2UDDI wadl2UDDI = new WADL2UDDI(clerk, properties);

                businessService businessServices = wadl2UDDI.createBusinessService(new QName("MyWasdl.namespace", "Servicename"), app);

                HashSet<tModel> portTypeTModels = wadl2UDDI.createWADLPortTypeTModels(url.ToString(), app);

                //When parsing a WSDL, there's really two things going on
                //1) convert a bunch of stuff (the portTypes) to tModels
                //2) convert the service definition to a BusinessService

                //Since the service depends on the tModel, we have to save the tModels first
                save_tModel tms = new save_tModel();
                tms.authInfo = clerk.getAuthToken(clerk.getUDDINode().getSecurityUrl());
                HashSet<tModel>.Enumerator it = portTypeTModels.GetEnumerator();
                List<tModel> ts = new List<tModel>();
                while (it.MoveNext())
                {
                    ts.Add(it.Current);
                }
                tModel[] tmodels = ts.ToArray();

                tms.tModel = tmodels;
                if (tms.tModel.Length > 0)
                    //important, you'll need to save your new tModels, or else saving the business/service may fail
                    publish.save_tModel(tms);

                //finaly, we're ready to save all of the services defined in the WSDL
                //again, we're creating a new business, if you have one already, look it up using the Inquiry getBusinessDetails

                // inquiry.find_tModel(new find_tModel

                save_business sb = new save_business();
                //  sb.setAuthInfo(rootAuthToken.getAuthInfo());
                businessEntity be = new businessEntity();
                be.businessKey = (businessServices.businessKey);
                //TODO, use some relevant here
                be.name = new name[] { new name(domain, "en") };

                be.businessServices = new businessService[] { businessServices };
                sb.authInfo = clerk.getAuthToken(clerk.getUDDINode().getSecurityUrl());
                sb.businessEntity = new businessEntity[] { be };
                publish.save_business(sb);
                Console.Out.WriteLine("Saved!");
            }
            catch (Exception ex)
            {
                while (ex != null)
                {
                    System.Console.WriteLine("Error! " + ex.Message);
                    ex = ex.InnerException;
                }
            }
            finally
            {
                if (transport != null && transport is IDisposable)
                {
                    ((IDisposable)transport).Dispose();
                }
                if (clerk != null)
                    clerk.Dispose();
            }
        }
Пример #5
0
 /// <summary>
 /// Constructs the serviceKey based on the serviceKeyFormat specified in the properties. When no
 ///serviceKeyFormat is specific the default format of uddi:${keyDomain}:${serviceName} is used.
 /// </summary>
 /// <param name="properties"></param>
 /// <param name="serviceName"></param>
 /// <returns></returns>
 public static String getServiceKey(Properties properties, String serviceName)
 {
     Properties tempProperties = new Properties();
     tempProperties.putAll(properties);
     tempProperties.put("serviceName", serviceName);
     //Constructing the serviceKey
     String keyFormat = tempProperties.getProperty(Property.SERVICE_KEY_FORMAT, DEFAULT_SERVICE_KEY_FORMAT);
     String serviceKey = TokenResolver.replaceTokens(keyFormat, tempProperties).ToLower();
     return serviceKey;
 }
Пример #6
0
        /**
         * fetches a wsdl endpoint and parses for execution urls
         * @param value
         * @return
         */
        private List<String> FetchWSDL(String value)
        {
            List<String> items = new List<String>();

            if (value.StartsWith("http://") || value.StartsWith("https://"))
            {
                //here, we need an HTTP Get for WSDLs
                org.apache.juddi.v3.client.mapping.ReadWSDL r = new ReadWSDL();
                r.setIgnoreSSLErrors(true);
                try
                {
                    tDefinitions wsdlDefinition = r.readWSDL(value);
                    Properties properties = new Properties();

                    properties.put("keyDomain", "domain");
                    properties.put("businessName", "biz");
                    properties.put("serverName", "localhost");
                    properties.put("serverPort", "80");

                    WSDL2UDDI wsdl2UDDI = new WSDL2UDDI(null, new URLLocalizer(), properties);
                    businessService[] businessServices = wsdl2UDDI.createBusinessServices(wsdlDefinition);
                    for (int i = 0; i < businessServices.Length; i++)
                    {
                        if (businessServices[i].bindingTemplates != null)
                        {
                            for (int k = 0; k < businessServices[i].bindingTemplates.Length; k++)
                            {
                                items.AddRange(ParseBinding(businessServices[i].bindingTemplates[k]));
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    log.error("error fetching wsdl for parsing", ex);
                }

            }
            return items;
        }
Пример #7
0
        void runTest(String pathAndFile)
        {
            Assume.That(File.Exists(pathAndFile));

            ReadWSDL wsi = new ReadWSDL();
            tDefinitions wsdlDefinition = wsi.readWSDL(
               pathAndFile
                );
            Properties properties1 = new Properties();
            properties1.put("keyDomain", "my.key.domain");
            WSDL2UDDI wsdl2UDDI = new WSDL2UDDI(null, new URLLocalizer(), properties1);
            Assert.NotNull(wsdl2UDDI);

            Dictionary<QName, tPortType> portTypes1 = (Dictionary<QName, tPortType>)wsdlDefinition.getAllPortTypes();
            Assert.NotNull(portTypes1);
            Assert.True(portTypes1.Count > 0);
            List<tModel> portTypeTModels1 = wsdl2UDDI.createWSDLPortTypeTModels(pathAndFile, portTypes1);

            Assert.NotNull(portTypeTModels1);
            Assert.True(portTypeTModels1.Count > 0);

            Dictionary<QName, tBinding> allBindings1 = wsdlDefinition.getAllBindings();
            Assert.NotNull(allBindings1);
            Assert.True(allBindings1.Count > 0);
            List<tModel> createWSDLBindingTModels1 = wsdl2UDDI.createWSDLBindingTModels(pathAndFile, allBindings1);
            Assert.NotNull(createWSDLBindingTModels1);
            Assert.True(createWSDLBindingTModels1.Count > 0);

            businessService[] businessServices = wsdl2UDDI.createBusinessServices(wsdlDefinition);

            Assert.NotNull(businessServices);
            Assert.True(businessServices.Length > 0);
            for (int i = 0; i < businessServices.Length; i++)
            {
                foreach (description d in businessServices[i].description)
                {
                    if (d.lang != null)
                        Assert.True(d.lang.Length <= UDDIConstants.MAX_xml_lang_length);
                    if (d.Value != null)
                        Assert.True(d.Value.Length <= UDDIConstants.MAX_description_length);
                }
                foreach (bindingTemplate bt in businessServices[i].bindingTemplates)
                {

                    Assert.NotNull(bt);
                    Assert.NotNull(bt.bindingKey);
                    Assert.NotNull(bt.Item);
                    Assert.NotNull(bt.serviceKey);
                    Assert.True(bt.Item is accessPoint);
                    Assert.NotNull(((accessPoint)bt.Item).useType);
                    Assert.NotNull(((accessPoint)bt.Item).Value);

                    foreach (description d in bt.description)
                    {
                        if (d.lang != null)
                            Assert.True(d.lang.Length <= UDDIConstants.MAX_xml_lang_length);
                        if (d.Value != null)
                            Assert.True(d.Value.Length <= UDDIConstants.MAX_description_length);
                    }

                    foreach (tModelInstanceInfo tm in bt.tModelInstanceDetails)
                    {
                        foreach (description d in tm.description)
                        {
                            if (d.lang != null)
                                Assert.True(d.lang.Length <= UDDIConstants.MAX_xml_lang_length);
                            if (d.Value != null)
                                Assert.True(d.Value.Length <= UDDIConstants.MAX_description_length);
                        }
                    }

                }
                Assert.True(businessServices[i].bindingTemplates.Length > 0);
                Assert.NotNull(businessServices[i].description);
                Assert.True(businessServices[i].description.Length > 0);
                Assert.NotNull(businessServices[i].serviceKey);
            }
        }
Пример #8
0
        void runTest(String pathAndFile)
        {
            Assume.That(File.Exists(pathAndFile));
            //Wadl Import example

            UDDIClient clerkManager = null;
            Transport transport = null;
            UDDIClerk clerk = null;
            clerkManager = new UDDIClient("uddi.xml");

            transport = clerkManager.getTransport("default");
            clerk = clerkManager.getClerk("default");

            application app = WADL2UDDI.ParseWadl(pathAndFile);
            List<Uri> urls = WADL2UDDI.GetBaseAddresses(app);
            Assert.True(urls.Count > 0);
            Uri url = urls[0];
            String domain = url.Host;

            tModel keygen = UDDIClerk.createKeyGenator("uddi:" + domain + ":keygenerator", domain, "en");
            Assert.NotNull(keygen);
            Assert.NotNull(keygen.tModelKey);
            Properties properties = new Properties();
            properties.put("keyDomain", domain);
            properties.put("businessName", domain);
            properties.put("serverName", url.Host);
            properties.put("serverPort", url.Port.ToString());
            WADL2UDDI wadl2UDDI = new WADL2UDDI(clerk, properties);
            businessService businessServices = wadl2UDDI.createBusinessService(new QName("MyWasdl.namespace", "Servicename"), app);
            if (serialize)
                Console.Out.WriteLine(new PrintUDDI<businessService>().print(businessServices));
            Assert.NotNull(businessServices);
            Assert.NotNull(businessServices.bindingTemplates);
            foreach (bindingTemplate bt in businessServices.bindingTemplates)
            {
                Assert.NotNull(bt);
                Assert.NotNull(bt.bindingKey);
                Assert.NotNull(bt.Item);
                Assert.NotNull(bt.serviceKey);
                Assert.True(bt.Item is accessPoint);
                Assert.NotNull(((accessPoint)bt.Item).useType);
                Assert.NotNull(((accessPoint)bt.Item).Value);
            }
            Assert.True(businessServices.bindingTemplates.Length > 0);
            Assert.NotNull(businessServices.description);
            Assert.True(businessServices.description.Length > 0);
            Assert.NotNull(businessServices.serviceKey);
        }
Пример #9
0
        public static void main(string[] args)
        {
            Console.Out.Write("Enter WSDL url: >");
            String input = Console.In.ReadLine();
            if (String.IsNullOrEmpty(input))
                input = "http://wsf.cdyne.com/WeatherWS/Weather.asmx?WSDL";
            //String wsdlURL = "http://wsf.cdyne.com/WeatherWS/Weather.asmx?WSDL";
            //if (String.IsNullOrEmpty(input))
            Uri url = null;
            String host = "localhost";
            int port = 80;
            try
            {
                url = new Uri(input);
                host = url.Host;
                port = url.Port;
            }
            catch { }
            ReadWSDL wsi = new ReadWSDL();
            tDefinitions wsdlDefinition = wsi.readWSDL(input);
            Properties properties1 = new Properties();
            properties1.put("serverName", host);
            properties1.put("businessName", host);
            properties1.put("keyDomain", "uddi:" + host);

            if (port <= 0)
            {
                if (url.ToString().StartsWith("https", StringComparison.CurrentCultureIgnoreCase))
                    port = 443;
                else port = 80;
            }
            properties1.put("serverPort", port.ToString());

            tModel keypart = UDDIClerk.createKeyGenator(host, host + "'s key partition", "en");

            WSDL2UDDI wsdl2UDDI = new WSDL2UDDI(null, new URLLocalizer(), properties1);
            List<tModel> tModels1 = new List<tModel>();

            Dictionary<QName, tPortType> portTypes1 = (Dictionary<QName, tPortType>)wsdlDefinition.getAllPortTypes();
            List<tModel> portTypeTModels1 = wsdl2UDDI.createWSDLPortTypeTModels(input, portTypes1);

            tModels1.AddRange(portTypeTModels1);

            Dictionary<QName, tBinding> allBindings1 = wsdlDefinition.getAllBindings();
            List<tModel> createWSDLBindingTModels1 = wsdl2UDDI.createWSDLBindingTModels(input, allBindings1);

            tModels1.AddRange(createWSDLBindingTModels1);
            businessService[] services = wsdl2UDDI.createBusinessServices(wsdlDefinition);

            save_service ss = new save_service();
            ss.businessService = services;
            Console.Out.WriteLine(new PrintUDDI<save_service>().print(ss));

            save_tModel st = new save_tModel();
            st.tModel = tModels1.ToArray();
            Console.Out.WriteLine(new PrintUDDI<save_tModel>().print(st));

            //save keypart

            //save tmodels
            //save business

            //TODO register the stuff
        }