public static string GetServiceLocation() { Console.WriteLine("Querying UDDI Registry..."); //Assign the network endpoint of UDDI Web services Inquire.Url = "http://test.uddi.microsoft.com/inquire"; //Find the provider FindBusiness findProvider = new FindBusiness(); findProvider.Names.Add("Vendor A"); BusinessList providerList = findProvider.Send(); BusinessInfo provider = providerList.BusinessInfos[0]; ServiceInfo providerService = provider.ServiceInfos[0]; //Find the Service details GetServiceDetail findService = new GetServiceDetail(); findService.ServiceKeys.Add(providerService.ServiceKey); ServiceDetail sd = findService.Send(); BusinessService service = sd.BusinessServices[0]; BindingTemplate template = service.BindingTemplates[0]; //Retrieve the service URL Console.WriteLine("Provider Endpoint : " + template.AccessPoint.Text); return(template.AccessPoint.Text); }
/// <summary> /// Gets the service object. /// </summary> /// <param name="UDDIConnection">The UDDI connection.</param> /// <param name="sName">Name of the service.</param> /// <returns></returns> public static BusinessService GetService(UddiConnection UDDIConnection, string sName) { GetServiceDetail sDetailObjList = new GetServiceDetail(); sDetailObjList.ServiceKeys.Add(GetServiceKey(UDDIConnection, sName)); ServiceDetail sDetailObj = sDetailObjList.Send(UDDIConnection); if (sDetailObj.BusinessServices.Count > 0) { return(sDetailObj.BusinessServices[0]); } return(null); }
/// <summary> /// Publica serviciul cu informatiile specificate in campurile corespunzatoare (daca nu exista deja). /// </summary> public void performPublish() { String businessName = txbBusinessName.Text.Trim(); String serviceName = txbServiceName.Text.Trim(); String accessPoint = txbAccessPoint.Text.Trim(); if (businessName == String.Empty || serviceName == String.Empty || accessPoint == String.Empty) { MessageBox.Show("All values must be set", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } try { FindBusiness findBusiness = new FindBusiness(businessName); findBusiness.FindQualifiers.Add(FindQualifier.ExactNameMatch); BusinessList businessList = findBusiness.Send(uddiConnection); if (0 == businessList.BusinessInfos.Count) { BusinessEntity newBusinessEntity = new BusinessEntity(businessName); BusinessService newBusinessService = new BusinessService(serviceName); newBusinessEntity.BusinessServices.Add(newBusinessService); BindingTemplate newBindingTemplate = new BindingTemplate(); newBindingTemplate.AccessPoint.Text = accessPoint; newBindingTemplate.AccessPoint.UrlType = UrlType.Http; selectOntologyForNewBindingTemplate(newBindingTemplate); newBusinessService.BindingTemplates.Add(newBindingTemplate); SaveBusiness saveNewBusiness = new SaveBusiness(newBusinessEntity); saveNewBusiness.Send(uddiConnection); } else { MessageBox.Show("Business already exists"); GetBusinessDetail getBusinessDetail = new GetBusinessDetail(businessList.BusinessInfos[0].BusinessKey); BusinessDetail businessDetail = getBusinessDetail.Send(uddiConnection); BusinessEntity oldBusinessEntity = businessDetail.BusinessEntities[0]; FindService findService = new FindService(serviceName); findService.FindQualifiers.Add(FindQualifier.ExactNameMatch); findService.BusinessKey = businessDetail.BusinessEntities[0].BusinessKey; ServiceList serviceList = findService.Send(uddiConnection); if (0 == serviceList.ServiceInfos.Count) { BusinessService newBusinessService = new BusinessService(serviceName); oldBusinessEntity.BusinessServices.Add(newBusinessService); BindingTemplate newBindingTemplate = new BindingTemplate(); newBindingTemplate.AccessPoint.Text = accessPoint; newBindingTemplate.AccessPoint.UrlType = UrlType.Http; selectOntologyForNewBindingTemplate(newBindingTemplate); newBusinessService.BindingTemplates.Add(newBindingTemplate); SaveBusiness saveOldBusiness = new SaveBusiness(oldBusinessEntity); saveOldBusiness.Send(uddiConnection); } else { MessageBox.Show("Service already exists"); GetServiceDetail getServiceDetail = new GetServiceDetail(serviceList.ServiceInfos[0].ServiceKey); ServiceDetail serviceDetail = getServiceDetail.Send(uddiConnection); BusinessService oldBusinessService = serviceDetail.BusinessServices[0]; foreach (BindingTemplate bindingTemplate in oldBusinessService.BindingTemplates) { if (bindingTemplate.AccessPoint.Text == accessPoint) { MessageBox.Show("Binding already exists"); return; } } BindingTemplate newBindingTemplate = new BindingTemplate(); newBindingTemplate.AccessPoint.Text = accessPoint; newBindingTemplate.AccessPoint.UrlType = UrlType.Http; selectOntologyForNewBindingTemplate(newBindingTemplate); oldBusinessService.BindingTemplates.Add(newBindingTemplate); SaveService saveOldService = new SaveService(oldBusinessService); saveOldService.Send(uddiConnection); } } MessageBox.Show("Publish successful", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (UddiException e) { MessageBox.Show("Uddi error: "+ e.Message, "Warning", MessageBoxButtons.OK, MessageBoxIcon.Error); } catch (Exception e){ MessageBox.Show("General exception: " + e.Message, "Warning", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
/// <summary> /// Cauta servicii pe baza informatiilor specificate pornind de la BusinessService. /// </summary> /// /// <param name="list">Lista cu informatii despre servicii, in care se fac adaugari</param> /// /// <param name="serviceList">Lista de grupuri de servicii</param> private void exploreServices(List<WSInfo> list, ServiceList serviceList) { WSInfo wsInfo; foreach (ServiceInfo serviceInfo in serviceList.ServiceInfos) { GetBusinessDetail getBusinessDetail = new GetBusinessDetail(serviceInfo.BusinessKey); BusinessDetail businessDetail = getBusinessDetail.Send(uddiConnection); GetServiceDetail getServiceDetail = new GetServiceDetail(serviceInfo.ServiceKey); ServiceDetail serviceDetail = getServiceDetail.Send(uddiConnection); foreach (BindingTemplate bindingTemplate in serviceDetail.BusinessServices[0].BindingTemplates) { if (ontologyAttributes != null && bindingTemplate.TModelInstanceInfos.Count !=0 ) { Boolean stop = false; for (int i=0;i < ontologyAttributes.Length && !stop; i = i+2) { for(int j=0;j < bindingTemplate.TModelInstanceInfos.Count && !stop; ++j) { if(bindingTemplate.TModelInstanceInfos[j].TModelKey == ontologyAttributes[i]) { wsInfo = new WSInfo(businessDetail.BusinessEntities[0].AuthorizedName, serviceInfo.BusinessKey, businessDetail.BusinessEntities[0].Names[0].Text, serviceInfo.ServiceKey, serviceInfo.Names[0].Text, bindingTemplate.BindingKey, bindingTemplate.AccessPoint.Text, ontologyAttributes[i + 1]); list.Add(wsInfo); stop = true; } } } } if (ontologyAttributes == null) { wsInfo = new WSInfo( businessDetail.BusinessEntities[0].AuthorizedName, serviceInfo.BusinessKey, businessDetail.BusinessEntities[0].Names[0].Text, serviceInfo.ServiceKey, serviceInfo.Names[0].Text, bindingTemplate.BindingKey, bindingTemplate.AccessPoint.Text, ""); list.Add(wsInfo); } } } }
/// <summary> /// Face un update al serviciilor retinute. /// </summary> /// <param name="UDDIAddress">Adresa serverului UDDI (inquire)</param> /// <param name="functionalitiesData">Informatii esentiale despre toate functionalitatile existente, pe baza carora se face cautarea de servicii.</param> public void updateServices(string UDDIAddress, string[] functionalitiesData) { if (functionalitiesData != null) { try { this.services = new Hashtable(); UddiConnection uddiConnection = new UddiConnection(UDDIAddress); FindService findService = new FindService("%"); ServiceList serviceList = findService.Send(uddiConnection); foreach (ServiceInfo serviceInfo in serviceList.ServiceInfos) { GetServiceDetail getServiceDetail = new GetServiceDetail(serviceInfo.ServiceKey); ServiceDetail serviceDetail = getServiceDetail.Send(uddiConnection); foreach (BindingTemplate bindingTemplate in serviceDetail.BusinessServices[0].BindingTemplates) { Boolean stop = false; for (int k = 0; k < functionalitiesData.Length && !stop; k = k + 3) { for (int j = 0; j < bindingTemplate.TModelInstanceInfos.Count && !stop; ++j) { if (bindingTemplate.TModelInstanceInfos[j].TModelKey == functionalitiesData[k]) { stop = true; string functionalityName = functionalitiesData[k + 1]; string accessPoint = string.Empty; if (bindingTemplate.AccessPoint.Text.ToLower().EndsWith("asmx")) { accessPoint = bindingTemplate.AccessPoint.Text + "?wsdl"; } if (bindingTemplate.AccessPoint.Text.ToLower().EndsWith("wsdl")) { accessPoint = bindingTemplate.AccessPoint.Text; } if (accessPoint != string.Empty) { XMLElement root = XMLParser.parse(accessPoint); if (root != null) { if (root.containsElements("wsdl:service")) { XMLElement service = root.getElements("wsdl:service")[0]; if (service.containsAttribute("name")) { string serviceName = service.getAttribute("name"); string ontologyPath = functionalitiesData[k + 2]; if (service.containsAttribute("sawsdl:modelReference")) { string annotationPath = service.getAttribute("sawsdl:modelReference"); //specificAnnotationSAWSDL this.addSpecificService(serviceName, accessPoint, functionalityName, ontologyPath, annotationPath); } else { //defaultAnnotationFromOntology this.addDefaultService(serviceName, accessPoint, functionalityName, ontologyPath); } } } } } } } } } } this._lastError = null; } catch (UddiException e) { this._lastError = "Uddi error: " + e.Message; } catch (Exception e) { this._lastError = "General exception:" + e.Message; } } else { this._lastError = "There are no functionalities. Try a functionalities update."; } }