Ejemplo n.º 1
0
 public static businessService MapService(uddi.apiv2.businessService businessService)
 {
     if (businessService == null) return null;
     businessService r = new businessService();
     r.bindingTemplates = MapBinding(businessService.bindingTemplates);
     r.businessKey = businessService.businessKey;
     r.categoryBag = MapCategoryBag(businessService.categoryBag);
     r.description = MapDescription(businessService.description);
     r.name = MapNames(businessService.name);
     r.serviceKey = businessService.serviceKey;
     return r;
 }
Ejemplo n.º 2
0
        /// <summary>
        /// 
        /// Creates a UDDI Business Service.
        /// 
        /// </summary>
        /// <param name="serviceQName"></param>
        /// <param name="wsdlDefinition"></param>
        /// <returns></returns>
        private businessService createBusinessService(QName serviceQName, xmlsoap.schemas.easyWsdl.tDefinitions wsdlDefinition)
        {
            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 = "";
            // Override with the service description from the WSDL if present
            org.xmlsoap.schemas.easyWsdl.tService svc = wsdlDefinition.getService(serviceQName);
            if (svc != null && svc.documentation != null)
            {
                HashSet<XmlNode>.Enumerator it = svc.documentation.Any.GetEnumerator();
                while (it.MoveNext())
                {

                    if (it.Current.Value != null)
                    {
                        serviceDescription += it.Current.Value;
                    }
                }

            }
            if (String.IsNullOrEmpty(serviceDescription))
            {
                serviceDescription = properties.getProperty(Property.SERVICE_DESCRIPTION, Property.DEFAULT_SERVICE_DESCRIPTION);
            }

            service.description = Common2UDDI.mapdescription(serviceDescription, lang).ToArray();
            // Service name
            name sName = new name();
            sName.lang = (lang);
            sName.Value = (serviceQName.getLocalPart());
            service.name = new name[] { sName };

            categoryBag categoryBag = new categoryBag();

            String ns = serviceQName.getNamespaceURI();
            List<keyedReference> cbitems = new List<keyedReference>();
            if (ns != null && ns != "")
            {
                keyedReference namespaceReference = newKeyedReference(
                        "uddi:uddi.org:xml:namespace", "uddi-org:xml:namespace", ns);
                cbitems.Add(namespaceReference);
            }

            keyedReference serviceReference = newKeyedReference(
                    "uddi:uddi.org:wsdl:types", "uddi-org:wsdl:types", "service");
            cbitems.Add(serviceReference);

            keyedReference localNameReference = newKeyedReference(
                    "uddi:uddi.org:xml:localname", "uddi-org:xml:localName", serviceQName.getLocalPart());
            cbitems.Add(localNameReference);
            categoryBag.Items = (object[])cbitems.ToArray();
            service.categoryBag = categoryBag;

            return service;
        }
Ejemplo n.º 3
0
        /**
         * This will setup new a business, service, and binding template that's
         * versioned per the article linked above
         */
        private void Setup()
        {
            businessEntity be = new businessEntity();
            keygen = clerk.register(UDDIClerk.createKeyGenator(domain_prefix + "keygenerator", "my domain", lang)).tModel[0];

            be.businessKey = (domain_prefix + "zerocoolbiz");
            be.name = new name[] { new name("ZeroCool Business", lang) };
            businessService bs = new businessService();
            bs.name = new name[] { new name("ZeroCool Service", lang) };

            bs.businessKey = (domain_prefix + "zerocoolbiz");
            bs.serviceKey = (domain_prefix + "zerocoolsvc");

            //version 1
            bindingTemplate bt1 = new bindingTemplate();
            String version = "1.0.0.0";
            bt1.bindingKey = (domain_prefix + "binding10");
            bt1.Item = (new accessPoint("http://localhost", "wsdl")) ;
            bt1.tModelInstanceDetails = new tModelInstanceInfo[] { UDDIClerk.createServiceInterfaceVersion(version, lang) };

            //version 2
            bindingTemplate bt2 = new bindingTemplate();
            bt2.bindingKey = (domain_prefix + "binding12");
            String version2 = "1.2.0.0";
            bt2.Item =  (new accessPoint("http://localhost", "wsdl")) ;
            bt2.tModelInstanceDetails = new tModelInstanceInfo[] { UDDIClerk.createServiceInterfaceVersion(version2, lang) };

            bs.bindingTemplates = new bindingTemplate[] { bt1, bt2 };
            be.businessServices = new businessService[] { bs };
            clerk.register(be);
        }
Ejemplo n.º 4
0
        public businessService readServiceAnnotations(String classWithAnnotations, Properties properties)
        {
            Type t = Type.GetType(classWithAnnotations, false, true);
            if (t != null)
            {
                businessService service = new businessService();
                object[] attrib = t.GetCustomAttributes(typeof(UDDIService), true);

                object[] ws = t.GetCustomAttributes(typeof(System.Web.Services.WebServiceBindingAttribute), true);
                WebServiceBindingAttribute webServiceAnnotation = null;
                if (ws != null && ws.Length > 0)
                {
                    webServiceAnnotation = ((WebServiceBindingAttribute[])ws)[0];
                }
                if (attrib != null && attrib.Length > 0)
                {

                    UDDIService[] bits = attrib as UDDIService[];
                    UDDIService uddiService = bits[0];
                    name n = new name();
                    n.lang = uddiService.lang;
                    service.businessKey = (TokenResolver.replaceTokens(uddiService.businessKey, properties));
                    service.serviceKey = (TokenResolver.replaceTokens(uddiService.serviceKey, properties));
                    if (!"".Equals(uddiService.serviceName, StringComparison.CurrentCultureIgnoreCase))
                    {
                        n.Value = (TokenResolver.replaceTokens(uddiService.serviceName, properties));
                    }
                    else if (webServiceAnnotation != null && !"".Equals(webServiceAnnotation.Name))
                    {
                        n.Value = (webServiceAnnotation.Name);
                    }
                    else
                    {
                        n.Value = (classWithAnnotations);
                    }
                    service.name = new name[] { n };
                    description d = new description();
                    d.lang = (uddiService.lang);
                    d.Value = (TokenResolver.replaceTokens(uddiService.description, properties));
                    service.description = new description[] { d };

                    //categoryBag on the service
                    if (!"".Equals(uddiService.categoryBag))
                    {
                        categoryBag categoryBag = parseCategoryBag(uddiService.categoryBag);
                        service.categoryBag = (categoryBag);
                    }

                    //bindingTemplate on service
                    bindingTemplate bindingTemplate = parseServiceBinding(classWithAnnotations, uddiService.lang, webServiceAnnotation, properties);
                    if (bindingTemplate != null)
                    {
                        bindingTemplate.serviceKey = (service.serviceKey);
                        if (service.bindingTemplates == null)
                        {
                            service.bindingTemplates = new bindingTemplate[] { bindingTemplate };
                        }
                        else
                        {
                            List<bindingTemplate> l = new List<bindingTemplate>();
                            l.AddRange(service.bindingTemplates);
                            l.Add(bindingTemplate);
                            service.bindingTemplates = l.ToArray();
                        }
                    }

                    return service;
                }
                else
                {
                    log.error("Missing UDDIService annotation in class " + classWithAnnotations);
                }
            }
            log.error("Unable to load type " + classWithAnnotations);
            return null;
        }
 public void setBusinessService(businessService businessService)
 {
     this.businessService = businessService;
 }
Ejemplo n.º 6
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;
        }
Ejemplo n.º 7
0
 private businessService NewBusinessService()
 {
     businessService bs = new businessService();
     bs.bindingTemplates = new bindingTemplate[] { NewBindingTempalte() };
     bs.businessKey = "asd";
     bs.categoryBag = new categoryBag();
     bs.categoryBag.Items = new object[] { new keyedReference("key", "name", "val") };
     bs.name = new name[] { new name("stuff", null) };
     bs.serviceKey = "asd";
     return bs;
 }
Ejemplo n.º 8
0
 private businessService getService()
 {
     businessService bs = new businessService();
     bs.serviceKey = "hello";
     bs.name = new name[] { new name("hi", "en") };
     bs.businessKey = "asd";
     return bs;
 }