/// <summary> /// Adds the service. /// </summary> /// <param name="pName">Name of the provider.</param> /// <param name="sName">Name of the service.</param> /// <param name="sDescription">The service description.</param> /// <param name="aPoint">Access point of the service.</param> /// <param name="categoryName">Name of the category.</param> /// <param name="keyName">Name of the key.</param> /// <param name="keyValue">The key value.</param> public void AddService(string pName, string sName, string sDescription, string aPoint, string categoryName, string keyName, string keyValue) { if (UDDISearcher.GetServiceKey(UDDIConnection, sName).Equals(String.Empty)) { BusinessService bService = UDDIDataCreater.CreateBusinessService(sName, sDescription); string bKey = UDDISearcher.GetBusinessKey(UDDIConnection, pName); bService.BusinessKey = bKey; bService.BindingTemplates.Add(UDDIDataCreater.CreateBindingTemplate(UDDIDataCreater.CreateAccessPoint(aPoint))); bService.CategoryBag.KeyedReferences.Add(UDDIDataCreater.CreateKeyedReference(UDDISearcher.GetTModelKey(UDDIConnection, categoryName), keyValue, keyName)); try { UDDIPublisher.SaveBusinessService(UDDIConnection, bService); } catch (Exception ex) { throw new Exception("Unable to add the service " + ex.Message); } } else { BusinessService bService = UDDISearcher.GetService(UDDIConnection, sName); bService.BindingTemplates.Add(UDDIDataCreater.CreateBindingTemplate(UDDIDataCreater.CreateAccessPoint(aPoint))); bService.CategoryBag.KeyedReferences.Add(UDDIDataCreater.CreateKeyedReference(UDDISearcher.GetTModelKey(UDDIConnection, categoryName), keyValue, keyName)); try { UDDIPublisher.SaveBusinessService(UDDIConnection, bService); } catch (Exception ex) { throw new Exception("Unable to add the service " + ex.Message); } } }
/// <summary> /// Adds the service to the provider. /// </summary> /// <param name="pName">Name of the provider.</param> /// <param name="aPoint">Access point.</param> /// <param name="categoryNameList">The category list for the service.</param> public void AddService(string pName, string aPoint, List <CategoryObject> categoryNameList) { //if service not exists if (UDDISearcher.GetServiceKey(UDDIConnection, categoryNameList[0].cName + " Service").Equals(String.Empty)) { //create service BusinessService bService = UDDIDataCreater.CreateBusinessService(categoryNameList[0].cName + " Service", "Service description for " + categoryNameList[0].cName + " Service"); string bKey = UDDISearcher.GetBusinessKey(UDDIConnection, pName); bService.BusinessKey = bKey; //create binding template of the service bService.BindingTemplates.Add(UDDIDataCreater.CreateBindingTemplate(UDDIDataCreater.CreateAccessPoint(aPoint))); KeyedReference kReference; for (int i = 0; i < categoryNameList.Count; i++) { kReference = UDDIDataCreater.CreateKeyedReference(UDDISearcher.GetTModelKey(UDDIConnection, categoryNameList[i].tModelName), UDDISearcher.GetCategory(UDDIConnection, categoryNameList[i].tModelName, categoryNameList[i].cName), categoryNameList[i].cName); //add category to the service if not exits if (!bService.CategoryBag.KeyedReferences.Contains(kReference)) { bService.CategoryBag.KeyedReferences.Add(kReference); } //add category to the binding template if not exits if (/*i > 0 && */ !bService.BindingTemplates[bService.BindingTemplates.Count - 1].CategoryBag.KeyedReferences.Contains(kReference)) { bService.BindingTemplates[bService.BindingTemplates.Count - 1].CategoryBag.KeyedReferences.Add(kReference); } } try { UDDIPublisher.SaveBusinessService(UDDIConnection, bService); } catch (Exception ex) { throw new Exception("Unable to add the service " + ex.Message); } } else { //find the service BusinessService bService = UDDISearcher.GetService(UDDIConnection, categoryNameList[0].cName + " Service"); BindingTemplate bTemplate = UDDIDataCreater.CreateBindingTemplate(UDDIDataCreater.CreateAccessPoint(aPoint)); //check if the binding already exists if (!bService.BindingTemplates.Contains(bTemplate, new BindigTemplateComparer())) { //add binding template to the service bService.BindingTemplates.Add(bTemplate); KeyedReference kReference; for (int i = 0; i < categoryNameList.Count; i++) { kReference = UDDIDataCreater.CreateKeyedReference(UDDISearcher.GetTModelKey(UDDIConnection, categoryNameList[i].tModelName), UDDISearcher.GetCategory(UDDIConnection, categoryNameList[i].tModelName, categoryNameList[i].cName), categoryNameList[i].cName); //add category to the service if not exits if (!bService.CategoryBag.KeyedReferences.Contains(kReference)) { bService.CategoryBag.KeyedReferences.Add(kReference); } //add category to the binding template if not exits if (/*i > 0 &&*/ !bService.BindingTemplates[bService.BindingTemplates.Count - 1].CategoryBag.KeyedReferences.Contains(kReference)) { bService.BindingTemplates[bService.BindingTemplates.Count - 1].CategoryBag.KeyedReferences.Add(kReference); } } try { UDDIPublisher.SaveBusinessService(UDDIConnection, bService); } catch (Exception ex) { throw new Exception("Unable to update the service " + ex.Message); } } } }