Ejemplo n.º 1
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;
 }
Ejemplo n.º 2
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;
        }
Ejemplo n.º 3
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;
        }
Ejemplo n.º 4
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;
        }