private static uddi.apiv2.keyedReference[] MapCategoryBag(uddi.apiv3.categoryBag categoryBag)
        {
            if (categoryBag == null)
            {
                return(null);
            }
            List <uddi.apiv2.keyedReference> names = new List <uddi.apiv2.keyedReference>();

            for (int i = 0; i < categoryBag.Items.Length; i++)
            {
                if (categoryBag.Items[i] is uddi.apiv3.keyedReference)
                {
                    uddi.apiv3.keyedReference kr = categoryBag.Items[i] as uddi.apiv3.keyedReference;
                    uddi.apiv2.keyedReference x  = new uddi.apiv2.keyedReference();
                    x.keyName   = kr.keyName;
                    x.keyValue  = kr.keyValue;
                    x.tModelKey = kr.tModelKey;
                    names.Add(x);
                }
            }
            return(names.ToArray());
        }
Esempio n. 2
0
        /// <summary>
        /// 
        /// &lt;h3&gt;2.4.1 wsdl:portType -&gt; uddi:tModel&lt;/h3&gt;
        /// 
        /// &lt;p&gt;A wsdl:portType MUST be modeled as a uddi:tModel.&lt;/p&gt;
        /// 
        /// &lt;p&gt;The minimum information that must be captured about a portType is its
        /// entity type, its local name, its namespace, and the location of the WSDL
        /// document that defines the portType. Capturing the entity type enables
        /// users to search for tModels that represent portType artifacts. Capturing
        /// the local name, namespace, and WSDL location enables users to locate the
        /// definition of the specified portType artifact.&lt;/p&gt;
        /// 
        /// &lt;p&gt;The wsdl:portType information is captured as follows:&lt;/p&gt;
        /// 
        /// &lt;p&gt;The uddi:name element of the tModel MUST be the value of the name
        /// attribute of the wsdl:portType.&lt;/p&gt;
        /// 
        /// &lt;p&gt;The tModel MUST contain a categoryBag, and the categoryBag MUST
        /// contain a keyedReference with a tModelKey of the WSDL Entity Type
        /// category system and a keyValue of &quot;portType&quot;.&lt;/p&gt;
        /// 
        /// &lt;p&gt;If the wsdl:portType has a targetNamespace then the categoryBag MUST
        /// also contain an additional keyedReference with a tModelKey of the XML
        /// Namespace category system and a keyValue of the target namespace of the
        /// wsdl:definitions element that contains the wsdl:portType. If the
        /// targetNamespace is absent from the portType, a categoryBag MUST NOT
        /// contain a keyedReference to the XML Namespace category system.&lt;/p&gt;
        /// 
        /// &lt;p&gt;The tModel MUST contain an overviewDoc with an overviewURL containing
        /// the location of the WSDL document that describes the wsdl:portType.&lt;/p&gt;
        /// Example Code
        /// &lt;pre&gt;
        /// URL url = new URL(&quot;http://graphical.weather.gov/xml/SOAP_server/ndfdXMLserver.php?wsdl&quot;);
        /// String domain = url.getHost();
        /// ReadWSDL rw = new ReadWSDL();
        /// Definition wsdlDefinition = rw.readWSDL(url);
        /// properties.put(&quot;keyDomain&quot;, domain);
        /// properties.put(&quot;businessName&quot;, domain);
        /// properties.put(&quot;serverName&quot;, url.getHost());
        /// properties.put(&quot;serverPort&quot;, url.getPort());
        /// wsdlURL = wsdlDefinition.getDocumentBaseURI();
        /// WSDL2UDDI wsdl2UDDI = new WSDL2UDDI(null, new URLLocalizerDefaultImpl(), properties);
        /// Map&lt;QName, PortType&gt; portTypes = (Map&lt;QName, PortType&gt;) wsdlDefinition.getAllPortTypes();
        /// Set&lt;TModel&gt; portTypeTModels = wsdl2UDDI.createWSDLPortTypeTModels(wsdlURL, portTypes);
        /// &lt;/pre&gt;
        /// 
        /// </summary>
        /// <param name="wsdlURL">This is used to set the Overview URL</param>
        /// <param name="portType">Map</param>
        /// @return set of WSDL PortType tModels
        /// <exception cref="Exception"></exception>
        public List<tModel> createWSDLBindingTModels(string wsdlURL, Dictionary<QName, xmlsoap.schemas.easyWsdl.tBinding> bindings)
        {
            List<tModel> tModels = new List<tModel>();
            Dictionary<QName, xmlsoap.schemas.easyWsdl.tBinding>.Enumerator it = bindings.GetEnumerator();
            while (it.MoveNext())
            {
                QName qName = it.Current.Key;
                String localpart = qName.getLocalPart();
                String ns = qName.getNamespaceURI();
                // Build the tModel
                tModel tModel = new tModel();
                // Set the Key
                tModel.tModelKey = (keyDomainURI + localpart);
                // Set the Name
                name name = new name();
                name.lang = (lang);
                name.Value = (localpart);
                tModel.name = (name);
                // Set the OverviewURL
                overviewURL overviewURL = new overviewURL();
                overviewURL.useType = (AccessPointType.wsdlDeployment.ToString());
                overviewURL.Value = (wsdlURL);
                overviewDoc overviewDoc = new overviewDoc();
                overviewDoc.overviewURLs = new overviewURL[] { (overviewURL) };
                tModel.overviewDoc = new overviewDoc[] { (overviewDoc) };
                // Set the categoryBag
                categoryBag categoryBag = new categoryBag();

                List<keyedReference> cbitems = new List<keyedReference>();
                if (ns != null && !"".Equals(ns))
                {
                    // A keyedReference with a tModelKey of the WSDL Entity Type category system and a keyValue of "binding".
                    keyedReference namespaceReference = newKeyedReference(
                            "uddi:uddi.org:xml:namespace", "uddi-org:xml:namespace", ns);
                    cbitems.Add(namespaceReference);
                }

                // A keyedReference with a tModelKey of the WSDL Entity Type category system and a keyValue of "binding".
                keyedReference typesReference = newKeyedReference(
                        "uddi:uddi.org:wsdl:types", "uddi-org:wsdl:types", "binding");
                cbitems.Add(typesReference);

                // A keyedReference with a tModelKey of the WSDL portType Reference category system and a keyValue
                // of the tModelKey that models the wsdl:portType to which the wsdl:binding relates.

                org.xmlsoap.schemas.easyWsdl.tBinding binding = bindings[(qName)];
                String portTypeKey = keyDomainURI + binding.type.Name;
                keyedReference namespaceReference2 = newKeyedReference(
                        "uddi:uddi.org:wsdl:porttypereference", "uddi-org:wsdl:portTypeReference",
                        portTypeKey);
                cbitems.Add(namespaceReference2);

                //  A keyedReference with a tModelKey of the UDDI Types category system and a keyValue of
                // "wsdlSpec" for backward compatibility.
                keyedReference typesReferenceBackwardsCompatible = newKeyedReference(
                        "uddi:uddi.org:categorization:types", "uddi-org:types", "wsdlSpec");
                cbitems.Add(typesReferenceBackwardsCompatible);

                // One or two keyedReferences as required to capture the protocol
                foreach (XmlElement xe in binding.Any)
                {

                    if (xe.NamespaceURI.Equals("http://schemas.xmlsoap.org/wsdl/soap/", StringComparison.CurrentCultureIgnoreCase)
                        && xe.LocalName.Equals("binding", StringComparison.CurrentCultureIgnoreCase))
                    {

                        // If the wsdl:binding contains a soap:binding extensibility element from the
                        // 'http://schemas.xmlsoap.org/wsdl/soap/' namespace then the categoryBag MUST
                        //include a keyedReference with a tModelKey of the Protocol Categorization
                        // category system and a keyValue of the tModelKey of the SOAP Protocol tModel.

                        keyedReference soapProtocol = newKeyedReference(
                                "uddi:uddi.org:wsdl:categorization:protocol", "uddi-org:protocol:soap", "uddi:uddi.org:protocol:soap");
                        cbitems.Add(soapProtocol);
                        // If the value of the transport attribute of the soap:binding element
                        // is 'http://schemas.xmlsoap.org/soap/http' then the categoryBag MUST
                        // include a keyedReference with a tModelKey of the Transport Categorization
                        // category system and a keyValue of the tModelKey of the HTTP Transport tModel.

                        if (String.IsNullOrEmpty(xe.GetAttribute("transport")))
                        {
                            // TODO If the value of the transport attribute is anything else,
                            // then the bindingTemplate MUST include an additional keyedReference with a tModelKey
                            // of the Transport Categorization category system and a keyValue of the tModelKey of
                            // an appropriate transport tModel.
                            log.warn("empty soap transport for binding " + it.Current.Key.getLocalPart() + " " + it.Current.Key.getNamespaceURI());
                        }
                        else
                        {
                            String attr = xe.GetAttribute("transport");

                            if (attr != null && attr.Equals("http://schemas.xmlsoap.org/soap/http"))
                            {
                                keyedReference httpTransport = newKeyedReference(
                                       "uddi:uddi.org:wsdl:categorization:transport", "uddi-org:http", "uddi:uddi.org:transport:http");
                                cbitems.Add(httpTransport);
                            }
                            else
                            {
                                log.warn("i don't know how to process the soap transport value of " + xe.GetAttribute("transport", "http://schemas.xmlsoap.org/wsdl/soap/"));
                            }
                        }
                    }
                    else if (xe.NamespaceURI.Equals("http://schemas.xmlsoap.org/wsdl/http/", StringComparison.CurrentCultureIgnoreCase)
                      && xe.LocalName.Equals("binding", StringComparison.CurrentCultureIgnoreCase))
                    {

                        // If the wsdl:binding contains an http:binding extensibility element from the
                        // http://schemas.xmlsoap.org/wsdl/http/ namespace then the categoryBag MUST
                        // include a keyedReference with a tModelKey of the Protocol Categorization
                        // category system and a keyValue of the tModelKey of the HTTP Protocol tModel.
                        keyedReference soapProtocol = newKeyedReference(
                                "uddi:uddi.org:wsdl:categorization:protocol", "uddi-org:protocol:http", "uddi:uddi.org:protocol:http");
                        cbitems.Add(soapProtocol);
                    }
                    else if (xe.NamespaceURI.Equals("http://schemas.xmlsoap.org/wsdl/soap12/", StringComparison.CurrentCultureIgnoreCase)
                        && xe.LocalName.Equals("binding", StringComparison.CurrentCultureIgnoreCase))
                    {
                        // If the wsdl:binding contains a soap:binding extensibility element from the
                        // 'http://schemas.xmlsoap.org/wsdl/soap/' namespace then the categoryBag MUST
                        //include a keyedReference with a tModelKey of the Protocol Categorization
                        // category system and a keyValue of the tModelKey of the SOAP Protocol tModel.

                        keyedReference soapProtocol = newKeyedReference(
                                "uddi:uddi.org:wsdl:categorization:protocol", "uddi-org:protocol:soap", "uddi:uddi.org:protocol:soap");
                        cbitems.Add(soapProtocol);
                        // If the value of the transport attribute of the soap:binding element
                        // is 'http://schemas.xmlsoap.org/soap/http' then the categoryBag MUST
                        // include a keyedReference with a tModelKey of the Transport Categorization
                        // category system and a keyValue of the tModelKey of the HTTP Transport tModel.

                        if (String.IsNullOrEmpty(xe.GetAttribute("transport")))
                        {
                            // TODO If the value of the transport attribute is anything else,
                            // then the bindingTemplate MUST include an additional keyedReference with a tModelKey
                            // of the Transport Categorization category system and a keyValue of the tModelKey of
                            // an appropriate transport tModel.
                            log.warn("empty soap transport for binding " + it.Current.Key.getLocalPart() + " " + it.Current.Key.getNamespaceURI());
                        }
                        else
                        {
                            String attr = xe.GetAttribute("transport");

                            if (attr != null && attr.Equals("http://schemas.xmlsoap.org/soap/http"))
                            {
                                keyedReference httpTransport = newKeyedReference(
                                       "uddi:uddi.org:wsdl:categorization:transport", "uddi-org:http", "uddi:uddi.org:transport:http");
                                cbitems.Add(httpTransport);
                            }
                            else
                            {
                                log.warn("i don't know how to process the soap transport value of " + xe.GetAttribute("transport", "http://schemas.xmlsoap.org/wsdl/soap/"));
                            }
                        }
                    }
                    else
                    {
                        log.warn("Unrecongnized binding type: " + xe.NamespaceURI + " " + xe.LocalName + ". Generated"
                            + "binding tModel may be missing the required (according to WSDL2UDDI spec) "
                            + "uddi:uddi.org:wsdl:categorization:protocol keyedReference.");
                    }
                }

                categoryBag = new uddi.apiv3.categoryBag();
                categoryBag.Items = cbitems.ToArray();
                tModel.categoryBag = categoryBag;
                tModels.Add(tModel);
            }
            return tModels;
        }