Example #1
0
        protected bindingTemplate createWADLBinding(QName serviceQName, String portName, Uri serviceUrl, resources res)
        {
            bindingTemplate bindingTemplate = new bindingTemplate();

            // Set BusinessService Key
            bindingTemplate.serviceKey = (UDDIKeyConvention.getServiceKey(properties, serviceQName.getLocalPart()));
            List <tModelInstanceInfo> items = new List <tModelInstanceInfo>();

            if (serviceUrl != null)
            {
                // Set AccessPoint
                accessPoint accessPoint = new accessPoint();
                accessPoint.useType  = (AccessPointType.endPoint.ToString());
                accessPoint.Value    = ((serviceUrl.ToString()));
                bindingTemplate.Item = (accessPoint);
                // Set Binding Key
                String bindingKey = UDDIKeyConvention.getBindingKey(properties, serviceQName, portName, serviceUrl);
                bindingTemplate.bindingKey = (bindingKey);

                bindingTemplate.description = Common2UDDI.mapdescription(getDescription(res.doc), lang).ToArray();

                // reference wsdl:binding tModel
                tModelInstanceInfo tModelInstanceInfoBinding = new tModelInstanceInfo();
                tModelInstanceInfoBinding.tModelKey = (keyDomainURI + "binding");
                instanceDetails id = new instanceDetails();
                id.instanceParms = portName;
                tModelInstanceInfoBinding.instanceDetails = (id);

                tModelInstanceInfoBinding.description = Common2UDDI.mapdescription("The binding that this endpoint implements. " + bindingTemplate.description[0].Value
                                                                                   + " The instanceParms specifies the port local name.", lang).ToArray();
                items.Add(tModelInstanceInfoBinding);

                tModelInstanceInfo tModelInstanceInfoPortType = new tModelInstanceInfo();
                tModelInstanceInfoPortType.tModelKey   = (keyDomainURI + "rest");
                tModelInstanceInfoPortType.description = Common2UDDI.mapdescription("The wadl:Resource:base implements.", lang).ToArray();
                items.Add(tModelInstanceInfoPortType);
            }
            bindingTemplate.tModelInstanceDetails = items.ToArray();
            return(bindingTemplate);
        }
Example #2
0
        /**
         * Creates a UDDI Business Service.
         *
         * @param serviceQName This must be specified to identify the namespace of
         * the service, which is used to set the service uddi key
         * @param waldDefinition
         * @return
         */
        public businessService createBusinessService(QName serviceQName, application wadlDefinition)
        {
            log.debug("Constructing Service UDDI Information for " + serviceQName);
            businessService service = new businessService();

            // BusinessKey
            service.businessKey = (businessKey);
            // ServiceKey
            service.serviceKey = (UDDIKeyConvention.getServiceKey(properties, serviceQName.getLocalPart()));
            // Description
            String serviceDescription = properties.getProperty(Property.SERVICE_DESCRIPTION, Property.DEFAULT_SERVICE_DESCRIPTION);
            // Override with the service description from the WSDL if present
            bool lengthwarn       = false;
            List <description> ds = new List <description>();

            if (wadlDefinition.doc != null)
            {
                for (int i = 0; i < wadlDefinition.doc.Length; i++)
                {
                    String      locallang   = lang;
                    description description = new description();
                    if (wadlDefinition.doc[i].lang != null)
                    {
                        locallang = (wadlDefinition.doc[i].lang);
                    }


                    if (locallang.Length > UDDIConstants.MAX_xml_lang_length)
                    {
                        lengthwarn = true;
                        locallang  = (locallang.Substring(0, UDDIConstants.MAX_xml_lang_length - 1));
                    }

                    StringBuilder sb = new StringBuilder();
                    sb.Append(wadlDefinition.doc[i].title).Append(" ");
                    sb.Append(ContentToString(wadlDefinition.doc[i].Any));

                    ds.AddRange(Common2UDDI.mapdescription(sb.ToString(), locallang));
                }
            }
            else
            {
                ds.AddRange(Common2UDDI.mapdescription(serviceDescription, lang));
            }
            service.description = ds.ToArray();


            // Service name
            name sName = new name();

            sName.lang = (lang);
            if (wadlDefinition.doc != null && wadlDefinition.doc.Length > 0)
            {
                sName.Value = (wadlDefinition.doc[0].title);
            }
            if (sName.Value == null)
            {
                sName.Value = (serviceQName.getLocalPart());
            }
            service.name = new name[] { sName };

            categoryBag           cb  = new categoryBag();
            List <keyedReference> krs = new List <keyedReference>();
            String ns = serviceQName.getNamespaceURI();

            if (ns != null && ns != "")
            {
                keyedReference namespaceReference = new keyedReference(
                    "uddi:uddi.org:xml:namespace", "uddi-org:xml:namespace", ns);
                krs.Add(namespaceReference);
            }

            keyedReference serviceReference = new keyedReference(
                "uddi:uddi.org:wadl:types", "uddi-org:wadl:types", "service");

            krs.Add(serviceReference);

            keyedReference localNameReference = new keyedReference(
                "uddi:uddi.org:xml:localname", "uddi-org:xml:localName", serviceQName.getLocalPart());

            krs.Add(localNameReference);
            cb.Items            = krs.ToArray();
            service.categoryBag = (cb);
            if (wadlDefinition.resources != null)
            {
                for (int i = 0; i < wadlDefinition.resources.Length; i++)
                {
                    bindingTemplate bindingTemplate = createWADLBinding(serviceQName, getDocTitle(wadlDefinition.resources[i].doc),
                                                                        new Uri(wadlDefinition.resources[i].@base), wadlDefinition.resources[i]);
                    service.bindingTemplates = new bindingTemplate[] { bindingTemplate };
                }
            }


            if (lengthwarn)
            {
                log.warn("Some object descriptions are longer than the maximum allowed by UDDI and have been truncated.");
            }
            return(service);
        }