示例#1
0
        /**
          * adds the typical SOAP tmodel references, but only if they aren't already present
          * @param bt
          * @return
          */
        public static bindingTemplate addSOAPtModels(bindingTemplate bt)
        {
            bool found = false;
            List<object> cbags = new List<object>();
            if (bt.categoryBag != null)
                cbags.AddRange(bt.categoryBag.Items);

            for (int i = 0; i < cbags.Count; i++)
            {
                if (cbags[i] is keyedReference)
                {
                    keyedReference kr = (keyedReference)cbags[i];
                    if (kr.tModelKey != null
                            && kr.tModelKey.Equals("uddi:uddi.org:categorization:types", StringComparison.CurrentCultureIgnoreCase))
                    {
                        if (kr.keyName != null
                                && kr.keyName.Equals("uddi-org:types:wsdl", StringComparison.CurrentCultureIgnoreCase))
                        {
                            found = true;
                        }
                    }
                }
            }
            if (!found)
                cbags.Add(new keyedReference("uddi:uddi.org:categorization:types", "uddi-org:types:wsdl", "wsdlDeployment"));
            if (cbags.Count > 0)
            {
                if (bt.categoryBag == null)
                    bt.categoryBag = new categoryBag();
                bt.categoryBag.Items = cbags.ToArray();
            }

            List<tModelInstanceInfo> data = new List<tModelInstanceInfo>();
            if (bt.tModelInstanceDetails != null)
            {
                data.AddRange(bt.tModelInstanceDetails);
            }
            accessPoint ap = null;
            if (bt.Item is accessPoint)
            {
                ap = (accessPoint)bt.Item;
            }
            tModelInstanceInfo tModelInstanceInfo;
            if (!Exists(data, UDDIConstants.PROTOCOL_SOAP))
            {
                tModelInstanceInfo = new tModelInstanceInfo();
                tModelInstanceInfo.tModelKey = (UDDIConstants.PROTOCOL_SOAP);
                data.Add(tModelInstanceInfo);
            }

            if (ap != null && ap.Value != null && ap.Value.StartsWith("http:"))
            {
                if (!Exists(data, UDDIConstants.TRANSPORT_HTTP))
                {
                    tModelInstanceInfo = new tModelInstanceInfo();
                    tModelInstanceInfo.tModelKey = (UDDIConstants.TRANSPORT_HTTP);
                    data.Add(tModelInstanceInfo);
                }
            }
            if (ap != null && ap.Value != null && ap.Value.StartsWith("jms:"))
            {
                if (!Exists(data, UDDIConstants.TRANSPORT_JMS))
                {
                    tModelInstanceInfo = new tModelInstanceInfo();
                    tModelInstanceInfo.tModelKey = (UDDIConstants.TRANSPORT_JMS);
                    data.Add(tModelInstanceInfo);
                }
            }
            if (ap != null && ap.Value != null && ap.Value.StartsWith("rmi:"))
            {
                if (!Exists(data, UDDIConstants.TRANSPORT_RMI))
                {
                    tModelInstanceInfo = new tModelInstanceInfo();
                    tModelInstanceInfo.tModelKey = (UDDIConstants.TRANSPORT_RMI);
                    data.Add(tModelInstanceInfo);
                }
            }
            if (ap != null && ap.Value != null && ap.Value.StartsWith("udp:"))
            {
                if (!Exists(data, UDDIConstants.TRANSPORT_UDP))
                {
                    tModelInstanceInfo = new tModelInstanceInfo();
                    tModelInstanceInfo.tModelKey = (UDDIConstants.TRANSPORT_UDP);
                    data.Add(tModelInstanceInfo);
                }
            }
            if (ap != null && ap.Value != null && ap.Value.StartsWith("amqp:"))
            {
                if (!Exists(data, UDDIConstants.TRANSPORT_AMQP))
                {
                    tModelInstanceInfo = new tModelInstanceInfo();
                    tModelInstanceInfo.tModelKey = (UDDIConstants.TRANSPORT_AMQP);
                    data.Add(tModelInstanceInfo);
                }
            }
            if (ap != null && ap.Value != null && ap.Value.StartsWith("mailto:"))
            {
                if (!Exists(data, UDDIConstants.TRANSPORT_EMAIL))
                {
                    tModelInstanceInfo = new tModelInstanceInfo();
                    tModelInstanceInfo.tModelKey = (UDDIConstants.TRANSPORT_EMAIL);
                    data.Add(tModelInstanceInfo);
                }
            }
            if (ap != null && ap.Value != null && ap.Value.StartsWith("ftp:"))
            {
                if (!Exists(data, UDDIConstants.TRANSPORT_FTP))
                {
                    tModelInstanceInfo = new tModelInstanceInfo();
                    tModelInstanceInfo.tModelKey = (UDDIConstants.TRANSPORT_FTP);
                    data.Add(tModelInstanceInfo);
                }
            }
            if (ap != null && ap.Value != null && ap.Value.StartsWith("https:"))
            {
                if (!Exists(data, UDDIConstants.PROTOCOL_SSLv3))
                {
                    tModelInstanceInfo = new tModelInstanceInfo();
                    tModelInstanceInfo.tModelKey = (UDDIConstants.PROTOCOL_SSLv3);
                    data.Add(tModelInstanceInfo);
                }
            }
            if (ap != null && ap.Value != null && ap.Value.StartsWith("ftps:"))
            {
                if (!Exists(data, UDDIConstants.PROTOCOL_SSLv3))
                {
                    tModelInstanceInfo = new tModelInstanceInfo();
                    tModelInstanceInfo.tModelKey = (UDDIConstants.PROTOCOL_SSLv3);
                    data.Add(tModelInstanceInfo);
                }
            }
            if (ap != null && ap.Value != null && ap.Value.StartsWith("jndi:"))
            {
                if (!Exists(data, UDDIConstants.TRANSPORT_JNDI_RMI))
                {
                    tModelInstanceInfo = new tModelInstanceInfo();
                    tModelInstanceInfo.tModelKey = (UDDIConstants.TRANSPORT_JNDI_RMI);
                    data.Add(tModelInstanceInfo);
                }
            }
            bt.tModelInstanceDetails = data.ToArray();
            return bt;
        }
示例#2
0
        /**
         * adds the typical REST tmodel references, but only if they aren't already present
         * @param bt
         * @return
         */
        public static bindingTemplate addRESTtModels(bindingTemplate bt)
        {
            List<tModelInstanceInfo> data = new List<tModelInstanceInfo>();
            if (bt.tModelInstanceDetails != null)
            {
                data.AddRange(bt.tModelInstanceDetails);
            }
            accessPoint ap = null;
            if (bt.Item is accessPoint)
            {
                ap = (accessPoint)bt.Item;
            }
            tModelInstanceInfo tModelInstanceInfo;
            if (!Exists(data, UDDIConstants.PROTOCOL_REST))
            {
                tModelInstanceInfo = new tModelInstanceInfo();
                tModelInstanceInfo.tModelKey = (UDDIConstants.PROTOCOL_REST);
                data.Add(tModelInstanceInfo);
            }

            if (ap != null && ap.Value != null && ap.Value.StartsWith("http:"))
            {
                if (!Exists(data, UDDIConstants.TRANSPORT_HTTP))
                {
                    tModelInstanceInfo = new tModelInstanceInfo();
                    tModelInstanceInfo.tModelKey = (UDDIConstants.TRANSPORT_HTTP);
                    data.Add(tModelInstanceInfo);
                }
            }
            if (ap != null && ap.Value != null && ap.Value.StartsWith("https:"))
            {
                if (!Exists(data, UDDIConstants.PROTOCOL_SSLv3))
                {
                    tModelInstanceInfo = new tModelInstanceInfo();
                    tModelInstanceInfo.tModelKey = (UDDIConstants.PROTOCOL_SSLv3);
                    data.Add(tModelInstanceInfo);
                }
            }
            bt.tModelInstanceDetails = data.ToArray();
            return bt;
        }
示例#3
0
        public void xr_bindingTemplate()
        {

            Console.Out.WriteLine("serialization bindingTemplate");
            bindingTemplate r = new bindingTemplate();
            XmlSerializer xr = new XmlSerializer(typeof(bindingTemplate));
            StringWriter sw = new StringWriter();
            xr.Serialize(sw, r);
            System.Console.Out.WriteLine(sw.ToString());
        }
示例#4
0
 public static bindingTemplate MapBindingTemplate(uddi.apiv2.bindingTemplate bindingTemplate)
 {
     if (bindingTemplate == null) return null;
     bindingTemplate r = new bindingTemplate();
     r.bindingKey = bindingTemplate.bindingKey;
     r.description = MapDescription(bindingTemplate.description);
     r.serviceKey = bindingTemplate.serviceKey;
     if (bindingTemplate.Item is org.uddi.apiv2.accessPoint)
     {
         org.uddi.apiv2.accessPoint old = new uddi.apiv2.accessPoint();
         accessPoint a = new accessPoint();
         a.Value = old.Value;
         a.useType = old.URLType.ToString();
         r.Item = a;
     }
     r.tModelInstanceDetails = MapTmodelInstanceDetail(bindingTemplate.tModelInstanceDetails);
     return r;
 }
示例#5
0
        private bindingTemplate createWSDLBinding(QName serviceQName, string portName, Uri serviceUrl, xmlsoap.schemas.easyWsdl.tDefinitions wsdlDefinition)
        {
            bindingTemplate bindingTemplate = new bindingTemplate();
            // Set BusinessService Key
            bindingTemplate.serviceKey = (UDDIKeyConvention.getServiceKey(properties, serviceQName.getLocalPart()));

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

            org.xmlsoap.schemas.easyWsdl.tService service = wsdlDefinition.getService(serviceQName);
            if (service != null)
            {
                List<tModelInstanceInfo> tii = new List<tModelInstanceInfo>();

                org.xmlsoap.schemas.easyWsdl.tPort port = service.getPort(portName);
                if (port != null)
                {
                    if (serviceUrl == null)
                    {
                        if (port.Any != null)
                        {
                            HashSet<XmlElement>.Enumerator it = port.Any.GetEnumerator();
                            while (it.MoveNext())
                            {
                                String location = null;
                                if (it.Current.LocalName.Equals("address", StringComparison.CurrentCultureIgnoreCase) &&
                                    it.Current.NamespaceURI.Equals("http://schemas.xmlsoap.org/wsdl/soap/", StringComparison.CurrentCultureIgnoreCase))
                                {

                                    location = it.Current.GetAttribute("location");
                                }
                                else
                                    if (it.Current.LocalName.Equals("address", StringComparison.CurrentCultureIgnoreCase) &&
                                    it.Current.NamespaceURI.Equals("http://schemas.xmlsoap.org/wsdl/http/", StringComparison.CurrentCultureIgnoreCase))
                                    {
                                        location = it.Current.GetAttribute("location");
                                    }
                                    else

                                        if (it.Current.LocalName.Equals("address", StringComparison.CurrentCultureIgnoreCase) &&
                                    it.Current.NamespaceURI.Equals("http://schemas.xmlsoap.org/wsdl/soap12/", StringComparison.CurrentCultureIgnoreCase))
                                        {
                                            location = it.Current.GetAttribute("location");
                                        }
                                if (location != null)
                                {
                                    try
                                    {
                                        Uri locationURI = new Uri(location);
                                        accessPoint accessPoint = new accessPoint();
                                        accessPoint.useType = (AccessPointType.endPoint.ToString());
                                        accessPoint.Value = (urlLocalizer.rewrite(locationURI));
                                        bindingTemplate.Item = (accessPoint);
                                        // Set Binding Key
                                        String bindingKey = UDDIKeyConvention.getBindingKey(properties, serviceQName, portName, locationURI);
                                        bindingTemplate.bindingKey = (bindingKey);
                                        break;
                                    }
                                    catch (Exception e)
                                    {
                                        log.error("", e);
                                    }
                                }
                            }
                        }

                    }
                    XmlQualifiedName bx = port.binding;
                    org.xmlsoap.schemas.easyWsdl.tBinding bindingelement = wsdlDefinition.getBinding(bx);
                    // Set the Binding Description
                    String bindingDescription = "";
                    // Override with the service description from the WSDL if present

                    if (bindingelement != null && bindingelement.documentation != null
                        && bindingelement.documentation.Any != null)
                    {
                        HashSet<XmlNode>.Enumerator it = bindingelement.documentation.Any.GetEnumerator();
                        while (it.MoveNext())
                        {
                            bindingDescription += it.Current.Value;
                        }
                    }
                    if (String.IsNullOrEmpty(bindingDescription))
                        bindingDescription = properties.getProperty(Property.BINDING_DESCRIPTION, Property.DEFAULT_BINDING_DESCRIPTION); ;

                    bindingTemplate.description = Common2UDDI.mapdescription(bindingDescription, lang).ToArray();

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

                    tModelInstanceInfoBinding.description = Common2UDDI.mapdescription("The wsdl:binding that this wsdl:port implements. " + bindingDescription
                            + " The instanceParms specifies the port local name.", lang).ToArray();
                    tii.Add(tModelInstanceInfoBinding);

                    // reference wsdl:portType tModel
                    org.xmlsoap.schemas.easyWsdl.tPortType portType = wsdlDefinition.getPortType(bindingelement.type);
                    tModelInstanceInfo tModelInstanceInfoPortType = new tModelInstanceInfo();
                    tModelInstanceInfoPortType.tModelKey = (keyDomainURI + portType.name);
                    String portTypeDescription = "";
                    if (portType.documentation != null && portType.documentation.Any != null)
                    {
                        HashSet<XmlNode>.Enumerator it = portType.documentation.Any.GetEnumerator();
                        while (it.MoveNext())
                        {
                            portTypeDescription += it.Current.Value;
                        }
                    }

                    tModelInstanceInfoPortType.description = Common2UDDI.mapdescription("The wsdl:portType that this wsdl:port implements." + portTypeDescription,lang).ToArray();
                    tii.Add(tModelInstanceInfoPortType);

                    bindingTemplate.tModelInstanceDetails = tii.ToArray();
                }
                else
                {
                    log.error("Could not find Port with portName: " + portName);
                }
            }
            else
            {
                log.error("Could not find Service with serviceName: " + serviceQName.getLocalPart());
            }

            return bindingTemplate;
        }
示例#6
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);
        }
示例#7
0
        private List<String> ParseBinding(bindingTemplate get)
        {
            List<String> items = new List<String>();
            if (get == null || get.Item == null)
            {
                return items;
            }
            if (get.Item is hostingRedirector)
            {
                //hosting Redirector is the same as "reference this other binding template". It's actually deprecated so
                //don't expect to see this too often
                items.AddRange(GetBindingInfo(((hostingRedirector)get.Item).bindingKey));
            }
            if (get.Item is accessPoint)
            {
                String usetype = ((accessPoint)get.Item).useType;
                if (usetype == null)
                {
                    //this is unexpected, usetype is a required field
                    items.Add(((accessPoint)get.Item).Value);
                }
                else if (usetype.Equals(AccessPointType.bindingTemplate.ToString(), StringComparison.CurrentCultureIgnoreCase))
                {
                    //referencing another binding template
                    items.AddRange(GetBindingInfo(((accessPoint)get.Item).Value));
                }
                else if (usetype.Equals(AccessPointType.hostingDirector.ToString(), StringComparison.CurrentCultureIgnoreCase))
                {
                    //this one is a bit strange. the value should be a binding template

                    items.AddRange(GetBindingInfo(((accessPoint)get.Item).Value));

                }
                else if (usetype.Equals(AccessPointType.wsdlDeployment.ToString(), StringComparison.CurrentCultureIgnoreCase))
                {
                    //fetch wsdl and parse
                    items.AddRange(FetchWSDL(((accessPoint)get.Item).Value));
                }
                else if (usetype.Equals(AccessPointType.endPoint.ToString(), StringComparison.CurrentCultureIgnoreCase))
                {
                    items.Add(((accessPoint)get.Item).Value);
                }
                else
                {
                    //treat it has an extension or whatever
                    items.Add(((accessPoint)get.Item).Value);
                }

            }

            return items;
        }
示例#8
0
 /// <summary>
 /// 
 /// This is a convenience function that will filter a list of binding templates
 /// and return a list of bindings matching the specified version number.
 /// 
 /// This implements and expands upon service versioning described in the
 /// following link and will enable you to tag web services
 /// registered in UDDI with some kind of version information.&lt;Br&gt;&lt;Br&gt;
 /// Article source: &lt;a href=&quot;http://www.ibm.com/developerworks/webservices/library/ws-version/&quot;&gt;http://www.ibm.com/developerworks/webservices/library/ws-version/&lt;/a&gt;
 /// &lt;Br&gt;&lt;Br&gt;
 /// </summary>
 /// <see cref="createServiceInterfaceVersion"></see>
 /// <see cref="createServiceInterfaceVersion"></see>
 /// <see cref="createServiceInterfaceVersion"></see>
 /// <see cref="createServiceInterfaceVersion"></see>
 /// <see cref="createServiceInterfaceVersion"></see>
 /// 
 /// This function operates using tModelInstances that are used to describe a
 /// version associated with either a service interface, a bindingTemplate
 /// service instance. Note: This is a jUDDI specific addon and may not be
 /// present in other registries
 /// 
 /// <param name="version">From the article, no specificity is provided on what to use as a value, but</param>
 /// we recommend that you use the string representation of major.minor[.build[.revision]].&lt;br&gt;
 /// Example
 /// &lt;ul&gt;
 /// &lt;li&gt;6.1.2.3&lt;/li&gt;
 /// &lt;li&gt;1.0&lt;/li&gt;
 /// &lt;li&gt;0.1&lt;/li&gt;
 /// &lt;/ul&gt;
 /// <param name="version"></param>
 /// <param name="bindingTemplate"></param>
 /// <returns>a list if binding templates where the version equals ignoring case trimmed equals the version value</returns>
 public static List<bindingTemplate> getBindingByVersion(String version, bindingTemplate[] bindingTemplate)
 {
     if (version == null)
     {
         throw new ArgumentNullException();
     }
     if (bindingTemplate == null)
     {
         throw new ArgumentNullException();
     }
     List<bindingTemplate> ret = new List<bindingTemplate>();
     for (int i = 0; i < bindingTemplate.Length; i++)
     {
         if (bindingTemplate[i].tModelInstanceDetails != null)
         {
             for (int k = 0; k < bindingTemplate[i].tModelInstanceDetails.Length; k++)
             {
                 if (bindingTemplate[i].tModelInstanceDetails[k].tModelKey.Equals(UDDIConstants.VERSION_TMODEL))
                 {
                     if (bindingTemplate[i].tModelInstanceDetails[k].instanceDetails != null)
                     {
                         if (bindingTemplate[i].tModelInstanceDetails[k].instanceDetails.instanceParms != null)
                         {
                             if ((bindingTemplate[i].tModelInstanceDetails[k].instanceDetails.instanceParms.Trim().Equals(version.Trim(), StringComparison.CurrentCultureIgnoreCase)))
                             {
                                 ret.Add(bindingTemplate[i]);
                             }
                         }
                     }
                 }
             }
         }
     }
     return ret;
 }
示例#9
0
        private bindingTemplate parseServiceBinding(string classWithAnnotations, string lang, WebServiceBindingAttribute webServiceAnnotation, Properties properties)
        {
            bindingTemplate bindingTemplate = null;
            Type t = Type.GetType(classWithAnnotations, false, false);
            UDDIServiceBinding uddiServiceBinding = null;
            object[] attrib = t.GetCustomAttributes(typeof(UDDIServiceBinding), true);
            if (attrib != null && attrib.Length > 0)
                uddiServiceBinding = attrib[0] as UDDIServiceBinding;

            //= (UDDIServiceBinding) classWithAnnotations.getAnnotation(UDDIServiceBinding.class);
            //binding
            if (uddiServiceBinding != null)
            {
                bindingTemplate = new bindingTemplate();

                bindingTemplate.bindingKey = (TokenResolver.replaceTokens(uddiServiceBinding.bindingKey, properties));

                String bindingLang = (lang);
                if (uddiServiceBinding.lang != null)
                {
                    bindingLang = TokenResolver.replaceTokens(uddiServiceBinding.lang, properties);
                }
                description bindingDescription = new description();
                bindingDescription.lang = (bindingLang);
                bindingDescription.Value = (TokenResolver.replaceTokens(uddiServiceBinding.description, properties));
                bindingTemplate.description = new description[] { (bindingDescription) };

                accessPoint accessPoint = new accessPoint();
                accessPoint.useType = (AccessPointType.wsdlDeployment.ToString());
                if (!"".Equals(uddiServiceBinding.accessPointType))
                {
                    accessPoint.useType = (uddiServiceBinding.accessPointType);
                }
                if (!"".Equals(uddiServiceBinding.accessPoint))
                {
                    String endPoint = uddiServiceBinding.accessPoint;
                    endPoint = TokenResolver.replaceTokens(endPoint, properties);
                    log.debug("AccessPoint EndPoint=" + endPoint);
                    accessPoint.Value = (endPoint);
                }
                else if (webServiceAnnotation != null && webServiceAnnotation.Location != null)
                {
                    accessPoint.Value = (webServiceAnnotation.Location);
                }
                bindingTemplate.Item = (accessPoint);

                //tModelKeys on the binding
                if (!"".Equals(uddiServiceBinding.tModelKeys))
                {
                    String[] tModelKeys = uddiServiceBinding.tModelKeys.Split(',');
                    foreach (String tModelKey in tModelKeys)
                    {
                        tModelInstanceInfo instanceInfo = new tModelInstanceInfo();
                        instanceInfo.tModelKey = (tModelKey);
                        if (bindingTemplate.tModelInstanceDetails == null)
                        {
                            bindingTemplate.tModelInstanceDetails = (new tModelInstanceInfo[] { instanceInfo });
                        }
                        List<tModelInstanceInfo> l = new List<tModelInstanceInfo>();
                        l.AddRange(bindingTemplate.tModelInstanceDetails);
                        l.Add(instanceInfo);
                        bindingTemplate.tModelInstanceDetails = l.ToArray();

                    }
                }
                //categoryBag on the binding
                if (!"".Equals(uddiServiceBinding.categoryBag))
                {
                    categoryBag categoryBag = parseCategoryBag(uddiServiceBinding.categoryBag);
                    bindingTemplate.categoryBag = (categoryBag);
                }
            }
            else
            {
                log.error("Missing UDDIServiceBinding annotation in class " + classWithAnnotations);
            }
            return bindingTemplate;
        }
示例#10
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;
        }
示例#11
0
 private bindingTemplate NewBindingTempalte()
 {
     bindingTemplate bt = new bindingTemplate();
     bt.bindingKey = "asd";
     bt.categoryBag = new categoryBag();
     bt.categoryBag.Items = new object[] { new keyedReference("key", "name", "val") };
     bt.description = new description[] { new description("hi", "en") };
     bt.Item = new accessPoint("http://localhost", "wsdl");
     bt.serviceKey = "svc";
     bt.tModelInstanceDetails = new tModelInstanceInfo[] { new tModelInstanceInfo() };
     return bt;
 }
        public static bindingTemplate start(UDDIClient client, String cfg_node_name, String endpoint,
            String keydomain, bool autoregister, String serviceKey,
            SignatureBehavior behavior)
        {
            if (instance == null)
            {
                instance = new SubscriptionCallbackListener();
            }

            if (ep != null && ep.State == CommunicationState.Opened)
            {
                throw new ServiceAlreadyStartedException();
            }

            Uri url = null;
            try
            {
                url = new Uri(endpoint);
            }
            catch (Exception ex)
            {
                log.warn("Callback endpoint couldn't be parsed, generating a random one: " + ex.Message);
                url = new Uri("http://" + GetHostname() + ":" + GetRandomPort(4000) + "/" + Guid.NewGuid().ToString());
            }
            endpoint = url.ToString();
            //if (endpoint == null || endpoint.equals("")) {
            //    endpoint = "http://" + GetHostname() + ":" + GetRandomPort(url.getPort()) + "/" + UUID.randomUUID().toString();

            int attempts = 5;
            if (ep == null)
            {
                while ((ep == null || ep.State != CommunicationState.Opened) && attempts > 0)
                {
                    try
                    {
                        if (endpoint.Contains("localhost"))
                            endpoint = endpoint.Replace("localhost", GetHostname());
                        ep = new ServiceHost(instance, new Uri[] { new Uri(endpoint) });
                        //ep = Endpoint.publish(endpoint, instance);
                        ep.Open();
                        callback = endpoint;
                    }
                    catch (Exception be)
                    {
                        log.info("trouble starting callback at " + endpoint + ", trying again with a random port: " + be.Message);
                        log.debug(be);
                        attempts--;
                        //if (be instanceof java.net.BindException) {
                        url = new Uri("http://" + url.Host + ":" + GetRandomPort(url.Port) + "/" + url.PathAndQuery);
                        endpoint = url.ToString();

                    }
                }
            }
            if (ep == null || ep.State != CommunicationState.Opened)
            {
                log.warn("Unable to start callback endpoint, aborting");
                throw new SecurityException("unable to start endpoint, view previous errors for reason");
            }

            log.info("Endpoint started at " + callback);

            bindingTemplate bt = new bindingTemplate();
            bt.Item = (new accessPoint(callback, "endPoint"));

            tModelInstanceInfo instanceInfo = new tModelInstanceInfo();
            instanceInfo.tModelKey = ("uddi:uddi.org:transport:http");
            bt.tModelInstanceDetails = new tModelInstanceInfo[] { instanceInfo };

            bt.serviceKey = (serviceKey);
            if (keydomain.EndsWith(":"))
            {
                bt.bindingKey = (keydomain + GetHostname() + "_Subscription_Callback");
            }
            else
            {
                bt.bindingKey = (keydomain + ":" + GetHostname() + "_Subscription_Callback");
            }

            if (autoregister)
            {
                bt = registerBinding(client, cfg_node_name, bt, behavior);
            }

            return bt;
        }
        /**
        * Registers a UDDI binding template that represents the subscription
        * callback endpoint
        *
        * @param client
        * @param cfg_node_name
        * @param bt - Binding Template
        * @param behavior
        * @return
        * @throws ServiceAlreadyStartedException
        * @throws SecurityException
        * @throws ConfigurationException
        * @throws TransportException
        * @throws DispositionReportFaultMessage
        * @throws RemoteException
        * @throws UnexpectedException
        * @throws RegistrationAbortedException
        * @throws UnableToSignException
        */
        public static bindingTemplate registerBinding(UDDIClient client, String cfg_node_name, bindingTemplate bt, SignatureBehavior behavior)
        {
            log.info("Attempting to register binding " + bt.bindingKey);
            UDDIClerk clerk = client.getClerk(cfg_node_name);
            Transport tp = client.getTransport(cfg_node_name);
            UDDI_Inquiry_SoapBinding uddiInquiryService = tp.getUDDIInquiryService();
            UDDI_Publication_SoapBinding uddiPublishService = tp.getUDDIPublishService();

            String token = clerk.getAuthToken(clerk.getUDDINode().getSecurityUrl());

            switch (behavior)
            {
                case SignatureBehavior.AbortIfSigned:
                    if (CheckExistingBindingForSignature(bt.bindingKey, uddiInquiryService, token, behavior))
                    {
                        throw new RegistrationAbortedException("Aborting, Either the item exists and is signed");
                    }
                    if (CheckServiceAndParentForSignature(bt.serviceKey, uddiInquiryService, token))
                    {
                        throw new RegistrationAbortedException("Aborting, Either the service or busness is signed");
                    }
                    break;
                case SignatureBehavior.DoNothing:
                    break;
                case SignatureBehavior.SignAlways:
                    try
                    {
                        DigSigUtil ds = new DigSigUtil(client.getClientConfig().getDigitalSignatureConfiguration());
                        bt = (bindingTemplate)ds.signUddiEntity(bt);
                    }
                    catch (Exception ex)
                    {
                        log.error("Unable to sign", ex);
                        throw new UnableToSignException("Unable to sign", ex);
                    }

                    break;
                case SignatureBehavior.SignOnlyIfParentIsntSigned:
                    if (!CheckServiceAndParentForSignature(bt.serviceKey, uddiInquiryService, token))
                    {
                        try
                        {
                            DigSigUtil ds = new DigSigUtil(client.getClientConfig().getDigitalSignatureConfiguration());
                            bt = (bindingTemplate)ds.signUddiEntity(bt);
                        }
                        catch (Exception ex)
                        {
                            log.error("Unable to sign", ex);
                            throw new UnableToSignException("Unable to sign", ex);
                        }
                    }
                    break;
            }
            save_binding sb = new save_binding();
            sb.authInfo = (token);
            sb.bindingTemplate = new bindingTemplate[] { bt };

            bindingDetail saveBinding = uddiPublishService.save_binding(sb);
            log.info("Binding registered successfully");
            if (saveBinding.bindingTemplate == null || saveBinding.bindingTemplate.Length > 1)
            {
                throw new UnexpectedResponseException("The number of binding templates returned was unexpected, count=" + (saveBinding.bindingTemplate == null ? "none" : saveBinding.bindingTemplate.Length.ToString()));
            }
            return saveBinding.bindingTemplate[0];
        }