コード例 #1
0
ファイル: WSDL2UDDITest.cs プロジェクト: lazycrazyowl/juddi
        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);
            }
        }
コード例 #2
0
ファイル: WsdlImport.cs プロジェクト: lazycrazyowl/juddi
        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
        }