/// <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; }
/// <summary> /// /// <h3>2.4.1 wsdl:portType -> uddi:tModel</h3> /// /// <p>A wsdl:portType MUST be modeled as a uddi:tModel.</p> /// /// <p>The minimum information that must be captured about a portType is its /// entity type, its local name, its namespace, and the location of the WSDL /// document that defines the portType. Capturing the entity type enables /// users to search for tModels that represent portType artifacts. Capturing /// the local name, namespace, and WSDL location enables users to locate the /// definition of the specified portType artifact.</p> /// /// <p>The wsdl:portType information is captured as follows:</p> /// /// <p>The uddi:name element of the tModel MUST be the value of the name /// attribute of the wsdl:portType.</p> /// /// <p>The tModel MUST contain a categoryBag, and the categoryBag MUST /// contain a keyedReference with a tModelKey of the WSDL Entity Type /// category system and a keyValue of "portType".</p> /// /// <p>If the wsdl:portType has a targetNamespace then the categoryBag MUST /// also contain an additional keyedReference with a tModelKey of the XML /// Namespace category system and a keyValue of the target namespace of the /// wsdl:definitions element that contains the wsdl:portType. If the /// targetNamespace is absent from the portType, a categoryBag MUST NOT /// contain a keyedReference to the XML Namespace category system.</p> /// /// <p>The tModel MUST contain an overviewDoc with an overviewURL containing /// the location of the WSDL document that describes the wsdl:portType.</p> /// Example Code /// <pre> /// URL url = new URL("http://graphical.weather.gov/xml/SOAP_server/ndfdXMLserver.php?wsdl"); /// String domain = url.getHost(); /// ReadWSDL rw = new ReadWSDL(); /// Definition wsdlDefinition = rw.readWSDL(url); /// properties.put("keyDomain", domain); /// properties.put("businessName", domain); /// properties.put("serverName", url.getHost()); /// properties.put("serverPort", url.getPort()); /// wsdlURL = wsdlDefinition.getDocumentBaseURI(); /// WSDL2UDDI wsdl2UDDI = new WSDL2UDDI(null, new URLLocalizerDefaultImpl(), properties); /// Map<QName, PortType> portTypes = (Map<QName, PortType>) wsdlDefinition.getAllPortTypes(); /// Set<TModel> portTypeTModels = wsdl2UDDI.createWSDLPortTypeTModels(wsdlURL, portTypes); /// </pre> /// /// </summary> /// <param name="wsdlURL">This is used to set the Overview URL</param> /// <param name="portTypes">Map</param> /// <returns>set of WSDL PortType tModels</returns> /// <exception cref="Exception"></exception> public List<tModel> createWSDLPortTypeTModels(string wsdlURL, Dictionary<QName, xmlsoap.schemas.easyWsdl.tPortType> portTypes) { List<tModel> tModels = new List<tModel>(); Dictionary<QName, xmlsoap.schemas.easyWsdl.tPortType>.Enumerator it = portTypes.GetEnumerator(); while (it.MoveNext()) { QName qName = it.Current.Key; tModel tModel = new tModel(); String localpart = qName.getLocalPart(); String ns = qName.getNamespaceURI(); // Set the Key tModel.tModelKey = (keyDomainURI + localpart); // Set the Name. The uddi:name element of the tModel MUST be the value of // the name attribute of the wsdl:portType. name name = new name(); name.lang = (lang); name.Value = (localpart); tModel.name = (name); // Set the OverviewURL. The tModel MUST contain an overviewDoc with an // overviewURL containing the location of the WSDL document that // describes the wsdl:portType. overviewURL overviewURL = new overviewURL(); overviewURL.useType = (AccessPointType.wsdlDeployment.ToString()); overviewURL.Value = (wsdlURL); overviewDoc overviewDoc = new overviewDoc(); overviewDoc.overviewURLs = new overviewURL[] { (overviewURL) }; tModel.overviewDoc = new overviewDoc[] { (overviewDoc) }; // Create the categoryBag, The tModel MUST contain a categoryBag categoryBag categoryBag = new categoryBag(); List<keyedReference> cbitems = new List<keyedReference>(); // the categoryBag MUST contain a keyedReference with a tModelKey of the WSDL // Entity Type category system and a keyValue of "portType". keyedReference typesReference = newKeyedReference( "uddi:uddi.org:wsdl:types", "uddi-org:wsdl:types", "portType"); cbitems.Add(typesReference); // If the wsdl:portType has a targetNamespace then the categoryBag MUST also contain an // additional keyedReference with a tModelKey of the XML Namespace category system and a // keyValue of the target namespace of the wsdl:definitions element that contains the // wsdl:portType. If the targetNamespace is absent from the portType, a categoryBag // MUST NOT contain a keyedReference to the XML Namespace category system. if (ns != null && !"".Equals(ns)) { keyedReference namespaceReference = newKeyedReference( "uddi:uddi.org:xml:namespace", "uddi-org:xml:namespace", ns); cbitems.Add(namespaceReference); } categoryBag.Items = (object[])cbitems.ToArray(); tModel.categoryBag = categoryBag; tModels.Add(tModel); } return tModels; }
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; }
/// <summary> /// /// <h3>2.4.1 wsdl:portType -> uddi:tModel</h3> /// /// <p>A wsdl:portType MUST be modeled as a uddi:tModel.</p> /// /// <p>The minimum information that must be captured about a portType is its /// entity type, its local name, its namespace, and the location of the WSDL /// document that defines the portType. Capturing the entity type enables /// users to search for tModels that represent portType artifacts. Capturing /// the local name, namespace, and WSDL location enables users to locate the /// definition of the specified portType artifact.</p> /// /// <p>The wsdl:portType information is captured as follows:</p> /// /// <p>The uddi:name element of the tModel MUST be the value of the name /// attribute of the wsdl:portType.</p> /// /// <p>The tModel MUST contain a categoryBag, and the categoryBag MUST /// contain a keyedReference with a tModelKey of the WSDL Entity Type /// category system and a keyValue of "portType".</p> /// /// <p>If the wsdl:portType has a targetNamespace then the categoryBag MUST /// also contain an additional keyedReference with a tModelKey of the XML /// Namespace category system and a keyValue of the target namespace of the /// wsdl:definitions element that contains the wsdl:portType. If the /// targetNamespace is absent from the portType, a categoryBag MUST NOT /// contain a keyedReference to the XML Namespace category system.</p> /// /// <p>The tModel MUST contain an overviewDoc with an overviewURL containing /// the location of the WSDL document that describes the wsdl:portType.</p> /// Example Code /// <pre> /// URL url = new URL("http://graphical.weather.gov/xml/SOAP_server/ndfdXMLserver.php?wsdl"); /// String domain = url.getHost(); /// ReadWSDL rw = new ReadWSDL(); /// Definition wsdlDefinition = rw.readWSDL(url); /// properties.put("keyDomain", domain); /// properties.put("businessName", domain); /// properties.put("serverName", url.getHost()); /// properties.put("serverPort", url.getPort()); /// wsdlURL = wsdlDefinition.getDocumentBaseURI(); /// WSDL2UDDI wsdl2UDDI = new WSDL2UDDI(null, new URLLocalizerDefaultImpl(), properties); /// Map<QName, PortType> portTypes = (Map<QName, PortType>) wsdlDefinition.getAllPortTypes(); /// Set<TModel> portTypeTModels = wsdl2UDDI.createWSDLPortTypeTModels(wsdlURL, portTypes); /// </pre> /// /// </summary> /// <param name="wsdlURL">This is used to set the Overview URL</param> /// <param name="portType">Map</param> /// @return set of WSDL PortType tModels /// <exception cref="Exception"></exception> public List<tModel> createWSDLBindingTModels(string wsdlURL, Dictionary<QName, xmlsoap.schemas.easyWsdl.tBinding> bindings) { List<tModel> tModels = new List<tModel>(); Dictionary<QName, xmlsoap.schemas.easyWsdl.tBinding>.Enumerator it = bindings.GetEnumerator(); while (it.MoveNext()) { QName qName = it.Current.Key; String localpart = qName.getLocalPart(); String ns = qName.getNamespaceURI(); // Build the tModel tModel tModel = new tModel(); // Set the Key tModel.tModelKey = (keyDomainURI + localpart); // Set the Name name name = new name(); name.lang = (lang); name.Value = (localpart); tModel.name = (name); // Set the OverviewURL overviewURL overviewURL = new overviewURL(); overviewURL.useType = (AccessPointType.wsdlDeployment.ToString()); overviewURL.Value = (wsdlURL); overviewDoc overviewDoc = new overviewDoc(); overviewDoc.overviewURLs = new overviewURL[] { (overviewURL) }; tModel.overviewDoc = new overviewDoc[] { (overviewDoc) }; // Set the categoryBag categoryBag categoryBag = new categoryBag(); List<keyedReference> cbitems = new List<keyedReference>(); if (ns != null && !"".Equals(ns)) { // A keyedReference with a tModelKey of the WSDL Entity Type category system and a keyValue of "binding". keyedReference namespaceReference = newKeyedReference( "uddi:uddi.org:xml:namespace", "uddi-org:xml:namespace", ns); cbitems.Add(namespaceReference); } // A keyedReference with a tModelKey of the WSDL Entity Type category system and a keyValue of "binding". keyedReference typesReference = newKeyedReference( "uddi:uddi.org:wsdl:types", "uddi-org:wsdl:types", "binding"); cbitems.Add(typesReference); // A keyedReference with a tModelKey of the WSDL portType Reference category system and a keyValue // of the tModelKey that models the wsdl:portType to which the wsdl:binding relates. org.xmlsoap.schemas.easyWsdl.tBinding binding = bindings[(qName)]; String portTypeKey = keyDomainURI + binding.type.Name; keyedReference namespaceReference2 = newKeyedReference( "uddi:uddi.org:wsdl:porttypereference", "uddi-org:wsdl:portTypeReference", portTypeKey); cbitems.Add(namespaceReference2); // A keyedReference with a tModelKey of the UDDI Types category system and a keyValue of // "wsdlSpec" for backward compatibility. keyedReference typesReferenceBackwardsCompatible = newKeyedReference( "uddi:uddi.org:categorization:types", "uddi-org:types", "wsdlSpec"); cbitems.Add(typesReferenceBackwardsCompatible); // One or two keyedReferences as required to capture the protocol foreach (XmlElement xe in binding.Any) { if (xe.NamespaceURI.Equals("http://schemas.xmlsoap.org/wsdl/soap/", StringComparison.CurrentCultureIgnoreCase) && xe.LocalName.Equals("binding", StringComparison.CurrentCultureIgnoreCase)) { // If the wsdl:binding contains a soap:binding extensibility element from the // 'http://schemas.xmlsoap.org/wsdl/soap/' namespace then the categoryBag MUST //include a keyedReference with a tModelKey of the Protocol Categorization // category system and a keyValue of the tModelKey of the SOAP Protocol tModel. keyedReference soapProtocol = newKeyedReference( "uddi:uddi.org:wsdl:categorization:protocol", "uddi-org:protocol:soap", "uddi:uddi.org:protocol:soap"); cbitems.Add(soapProtocol); // If the value of the transport attribute of the soap:binding element // is 'http://schemas.xmlsoap.org/soap/http' then the categoryBag MUST // include a keyedReference with a tModelKey of the Transport Categorization // category system and a keyValue of the tModelKey of the HTTP Transport tModel. if (String.IsNullOrEmpty(xe.GetAttribute("transport"))) { // TODO If the value of the transport attribute is anything else, // then the bindingTemplate MUST include an additional keyedReference with a tModelKey // of the Transport Categorization category system and a keyValue of the tModelKey of // an appropriate transport tModel. log.warn("empty soap transport for binding " + it.Current.Key.getLocalPart() + " " + it.Current.Key.getNamespaceURI()); } else { String attr = xe.GetAttribute("transport"); if (attr != null && attr.Equals("http://schemas.xmlsoap.org/soap/http")) { keyedReference httpTransport = newKeyedReference( "uddi:uddi.org:wsdl:categorization:transport", "uddi-org:http", "uddi:uddi.org:transport:http"); cbitems.Add(httpTransport); } else { log.warn("i don't know how to process the soap transport value of " + xe.GetAttribute("transport", "http://schemas.xmlsoap.org/wsdl/soap/")); } } } else if (xe.NamespaceURI.Equals("http://schemas.xmlsoap.org/wsdl/http/", StringComparison.CurrentCultureIgnoreCase) && xe.LocalName.Equals("binding", StringComparison.CurrentCultureIgnoreCase)) { // If the wsdl:binding contains an http:binding extensibility element from the // http://schemas.xmlsoap.org/wsdl/http/ namespace then the categoryBag MUST // include a keyedReference with a tModelKey of the Protocol Categorization // category system and a keyValue of the tModelKey of the HTTP Protocol tModel. keyedReference soapProtocol = newKeyedReference( "uddi:uddi.org:wsdl:categorization:protocol", "uddi-org:protocol:http", "uddi:uddi.org:protocol:http"); cbitems.Add(soapProtocol); } else if (xe.NamespaceURI.Equals("http://schemas.xmlsoap.org/wsdl/soap12/", StringComparison.CurrentCultureIgnoreCase) && xe.LocalName.Equals("binding", StringComparison.CurrentCultureIgnoreCase)) { // If the wsdl:binding contains a soap:binding extensibility element from the // 'http://schemas.xmlsoap.org/wsdl/soap/' namespace then the categoryBag MUST //include a keyedReference with a tModelKey of the Protocol Categorization // category system and a keyValue of the tModelKey of the SOAP Protocol tModel. keyedReference soapProtocol = newKeyedReference( "uddi:uddi.org:wsdl:categorization:protocol", "uddi-org:protocol:soap", "uddi:uddi.org:protocol:soap"); cbitems.Add(soapProtocol); // If the value of the transport attribute of the soap:binding element // is 'http://schemas.xmlsoap.org/soap/http' then the categoryBag MUST // include a keyedReference with a tModelKey of the Transport Categorization // category system and a keyValue of the tModelKey of the HTTP Transport tModel. if (String.IsNullOrEmpty(xe.GetAttribute("transport"))) { // TODO If the value of the transport attribute is anything else, // then the bindingTemplate MUST include an additional keyedReference with a tModelKey // of the Transport Categorization category system and a keyValue of the tModelKey of // an appropriate transport tModel. log.warn("empty soap transport for binding " + it.Current.Key.getLocalPart() + " " + it.Current.Key.getNamespaceURI()); } else { String attr = xe.GetAttribute("transport"); if (attr != null && attr.Equals("http://schemas.xmlsoap.org/soap/http")) { keyedReference httpTransport = newKeyedReference( "uddi:uddi.org:wsdl:categorization:transport", "uddi-org:http", "uddi:uddi.org:transport:http"); cbitems.Add(httpTransport); } else { log.warn("i don't know how to process the soap transport value of " + xe.GetAttribute("transport", "http://schemas.xmlsoap.org/wsdl/soap/")); } } } else { log.warn("Unrecongnized binding type: " + xe.NamespaceURI + " " + xe.LocalName + ". Generated" + "binding tModel may be missing the required (according to WSDL2UDDI spec) " + "uddi:uddi.org:wsdl:categorization:protocol keyedReference."); } } categoryBag = new uddi.apiv3.categoryBag(); categoryBag.Items = cbitems.ToArray(); tModel.categoryBag = categoryBag; tModels.Add(tModel); } return tModels; }
/** * 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; }