public void testCompareToDate() { System.Console.Out.WriteLine("TModelInstanceDetailsComparator.compare testCompareToDate"); tModelInstanceInfo[] lhs = new tModelInstanceInfo[1] { new tModelInstanceInfo() }; lhs[0].tModelKey = ("hi"); lhs[0].instanceDetails = new instanceDetails(); lhs[0].instanceDetails.instanceParms = ("asdasd"); tModelInstanceInfo[] rhs = new tModelInstanceInfo[1] { new tModelInstanceInfo() }; rhs[0].tModelKey = ("hi"); rhs[0].instanceDetails = new instanceDetails(); rhs[0].instanceDetails.instanceParms = ("asdasdasd"); TModelInstanceDetailsComparator instance = new TModelInstanceDetailsComparator("hi", false, true, false); int result = instance.compare(lhs, rhs); //Assert.assertTrue("result " + result,result < 0); }
public void testCompareToDateEQ() { System.Console.Out.WriteLine("TModelInstanceDetailsComparator.compare testCompareToDateEQ"); tModelInstanceInfo[] lhs = new tModelInstanceInfo[1] { new tModelInstanceInfo() }; lhs[0].tModelKey = ("hi"); lhs[0].instanceDetails = new instanceDetails(); lhs[0].instanceDetails.instanceParms = ("2002-05-30T09:30:10-06:00"); tModelInstanceInfo[] rhs = new tModelInstanceInfo[1] { new tModelInstanceInfo() }; rhs[0].tModelKey = ("hi"); rhs[0].instanceDetails = new instanceDetails(); rhs[0].instanceDetails.instanceParms = ("2002-05-30T09:30:10-06:00"); TModelInstanceDetailsComparator instance = new TModelInstanceDetailsComparator("hi", false, true, false); int result = instance.compare(lhs, rhs); Assert.True(result == 0, "result " + lhs[0].instanceDetails.instanceParms + " compare to " + rhs[0].instanceDetails.instanceParms + " " + result); }
/** * Compares two non-null instances of TModelInstanceDetails by only * comparing the field designated from the constructor. It will also cast or * parse TModelInstanceDetails[i].InstanceDetails[k].InstanceParms to the * selected data type double, XMLGregorgian or Duration, using that as a * basis for comparison. If a parsing error occurs, an exception will be * thrown. * * @param lhs * @param rhs * @return less than 0 if lhs < rhs, greater than 0 if lhs > rhs. * @throws IllegalArgumentException if the tModel key to search for is * missing, if either sides are null * @throws ArrayIndexOutOfBoundsException if the values were found but could * not be compared * throws IllegalArgumentException, NumberFormatException, NullPointerException, ArrayIndexOutOfBoundsException */ public int compare(tModelInstanceInfo[] lhs, tModelInstanceInfo[] rhs) { if (lhs == null) { throw new ArgumentNullException("lhs"); } if (rhs == null) { throw new ArgumentNullException("rhs"); } if (lhs.Length == 0 || rhs.Length == 0) { throw new ArgumentOutOfRangeException("no data to compare"); } instanceDetails lhsc = null; instanceDetails rhsc = null; for (int i = 0; i < lhs.Length; i++) { if (lhs[i].tModelKey!=null && lhs[i].tModelKey.Equals(compareField, StringComparison.CurrentCultureIgnoreCase)) { lhsc = lhs[i].instanceDetails; } } for (int i = 0; i < rhs.Length; i++) { if (rhs[i].tModelKey!=null && rhs[i].tModelKey.Equals(compareField, StringComparison.CurrentCultureIgnoreCase)) { rhsc = rhs[i].instanceDetails; } } if (lhsc == null) { throw new ArgumentOutOfRangeException(compareField + " not found for lhs"); } if (rhsc == null) { throw new ArgumentOutOfRangeException(compareField + " not found for rhs"); } if (lhsc.instanceParms == null) { throw new ArgumentOutOfRangeException(compareField + " found lhs, but no data"); } if (rhsc.instanceParms == null) { throw new ArgumentOutOfRangeException(compareField + " found rhs, but no data"); } if (isNumber) { Double l = Double.Parse(lhsc.instanceParms); Double r = Double.Parse(rhsc.instanceParms); return l.CompareTo(r); } if (isDate) { DateTime l = XmlConvert.ToDateTime(lhsc.instanceParms); DateTime r = XmlConvert.ToDateTime(rhsc.instanceParms); int x = l.CompareTo(r); return x; } if (isDuration) { TimeSpan l = XmlConvert.ToTimeSpan(lhsc.instanceParms); TimeSpan r = XmlConvert.ToTimeSpan(rhsc.instanceParms); int x = l.CompareTo(r); return x; } return 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; }
/** * 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; }
public static tModelInstanceInfo[] MapTmodelInstanceDetail(uddi.apiv2.tModelInstanceInfo[] tModelInstanceInfo) { if (tModelInstanceInfo == null) return null; List<tModelInstanceInfo> r = new List<tModelInstanceInfo>(); for (int i = 0; i < tModelInstanceInfo.Length; i++) { tModelInstanceInfo x = new tModelInstanceInfo(); x.description = MapDescription(tModelInstanceInfo[i].description); x.tModelKey = tModelInstanceInfo[i].tModelKey; x.instanceDetails = MapInstanceDetails(tModelInstanceInfo[i].instanceDetails); r.Add(x); } return r.ToArray(); }
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; }
public void testCompareToRHSNull() { System.Console.Out.WriteLine("TModelInstanceDetailsComparator.compare testCompareToRHSNull"); tModelInstanceInfo[] lhs = new tModelInstanceInfo[1] { new tModelInstanceInfo() }; lhs[0].tModelKey = ("hi"); lhs[0].instanceDetails = new instanceDetails(); lhs[0].instanceDetails.instanceParms = ("xyz"); tModelInstanceInfo[] rhs = new tModelInstanceInfo[1] { new tModelInstanceInfo() }; rhs[0].tModelKey = ("hi"); rhs[0].instanceDetails = new instanceDetails(); //rhs[0].instanceDetails.instanceParms=("xyz"); TModelInstanceDetailsComparator instance = new TModelInstanceDetailsComparator("hi", true, false, false); int expResult = 0; int result = instance.compare(lhs, rhs); }
public void testCompareToNumberDataLT() { System.Console.Out.WriteLine("TModelInstanceDetailsComparator.compare testCompareToNumberDataLT"); tModelInstanceInfo[] lhs = new tModelInstanceInfo[1] { new tModelInstanceInfo() }; lhs[0].tModelKey = ("hi"); lhs[0].instanceDetails = new instanceDetails(); lhs[0].instanceDetails.instanceParms = ("3.10"); tModelInstanceInfo[] rhs = new tModelInstanceInfo[1] { new tModelInstanceInfo() }; rhs[0].tModelKey = ("hi"); rhs[0].instanceDetails = new instanceDetails(); rhs[0].instanceDetails.instanceParms = ("3.14"); TModelInstanceDetailsComparator instance = new TModelInstanceDetailsComparator("hi", true, false, false); int result = instance.compare(lhs, rhs); Assert.True(result < 0, "result " + result); }
public void testCompareToNotFound() { System.Console.Out.WriteLine("TModelInstanceDetailsComparator.compare notfound"); tModelInstanceInfo[] lhs = new tModelInstanceInfo[1] { new tModelInstanceInfo() }; lhs[0].tModelKey = ("asd"); tModelInstanceInfo[] rhs = new tModelInstanceInfo[1] { new tModelInstanceInfo() }; rhs[0].tModelKey = ("asd"); rhs[0].instanceDetails = new instanceDetails(); TModelInstanceDetailsComparator instance = new TModelInstanceDetailsComparator("hi", true, false, false); int expResult = 0; int result = instance.compare(lhs, rhs); }
public void testCompareToNulls7() { System.Console.Out.WriteLine("TModelInstanceDetailsComparator.compare nulls7"); tModelInstanceInfo[] lhs = new tModelInstanceInfo[1] { new tModelInstanceInfo() }; tModelInstanceInfo[] rhs = new tModelInstanceInfo[1] { new tModelInstanceInfo() }; TModelInstanceDetailsComparator instance = new TModelInstanceDetailsComparator("hi", true, false, false); int expResult = 0; int result = instance.compare(lhs, rhs); }
public void testCompareToDurationInvalid() { System.Console.Out.WriteLine("TModelInstanceDetailsComparator.compare testCompareToDurationInvalid"); tModelInstanceInfo[] lhs = new tModelInstanceInfo[1] { new tModelInstanceInfo() }; lhs[0].tModelKey = ("hi"); lhs[0].instanceDetails = new instanceDetails(); lhs[0].instanceDetails.instanceParms = ("asdasd"); tModelInstanceInfo[] rhs = new tModelInstanceInfo[1] { new tModelInstanceInfo() }; rhs[0].tModelKey = ("hi"); rhs[0].instanceDetails = new instanceDetails(); rhs[0].instanceDetails.instanceParms = ("asdasd"); TModelInstanceDetailsComparator instance = new TModelInstanceDetailsComparator("hi", false, false, true); int result = instance.compare(lhs, rhs); Assert.True(result == 0, "result " + result); }
/// <summary> /// /// This is a convenience function that will build and return a TModelInstanceInfo /// as described in the following link that will enable you to tag web services /// registered in UDDI with some kind of version information.<Br><Br> /// Article source: <a href="http://www.ibm.com/developerworks/webservices/library/ws-version/">http://www.ibm.com/developerworks/webservices/library/ws-version/</a> /// <Br><Br> /// /// When using this tModel as a tModelInstance, it can be 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 /// /// </summary> /// <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]].<br> /// Example /// <ul> /// <li>6.1.2.3</li> /// <li>1.0</li> /// <li>0.1</li> /// </ul> /// <returns>TModelInstanceInfo populated as described in the article, plus some descriptive information</returns> public static tModelInstanceInfo createServiceInterfaceVersion(String version, String lang) { if (version == null) throw new ArgumentNullException(); tModelInstanceInfo tt = new tModelInstanceInfo(); tt.tModelKey = (UDDIConstants.VERSION_TMODEL); tt.instanceDetails = new instanceDetails(); overviewDoc doc = new overviewDoc(); doc.overviewURLs = new overviewURL[] { (new overviewURL("http://www.ibm.com/developerworks/webservices/library/ws-version/", "text")) }; //,new description( //"Describes a version associated with either a service interface, a bindingTemplate service instance.", lang)}; tt.description = new description[] { new description("Describes a version associated with either a service interface, a bindingTemplate service instance.", lang) }; tt.instanceDetails.Items = new overviewDoc[] { doc }; tt.instanceDetails.instanceParms = version; //tt.instanceDetails.Items = new object[] { doc }; return tt; }
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; }
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; }
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; }