
Introduction
Universal Description, Discovery, and Integration (UDDI) is a platform-independent, XML-based registry for businesses worldwide to list themselves on the Internet. UDDI is an important part in Web Services architecture. Clients can find information about a Web Service by using a UDDI server. In this article, we will present the basic steps to interact with a UDDI server.
Using the code
Library
To interact with a UDDI server, we can use the library Microsoft.Uddi.dll. This DLL can be found in the Microsoft Platform SDK for Windows Server 2003 R2. You can download this entire platform (about 1 GB) from the Microsoft site or use the one in this demo.
Search
The URL used to search is http://domain/uddipublic/inquire.asmx. We will use a FindService object for this operation, and login is not required.
Microsoft.Uddi.Inquire.Url = url;
Microsoft.Uddi.Inquire.AuthenticationMode =
Microsoft.Uddi.AuthenticationMode.UddiAuthentication;
FindService fs = new FindService();
if (businessKey != String.Empty)
Microsoft.Uddi.Inquire.Url = url;
Microsoft.Uddi.Inquire.AuthenticationMode =
Microsoft.Uddi.AuthenticationMode.UddiAuthentication;
fs.BusinessKey = businessKey;
fs.FindQualifiers = _qualifiers;
if (_tTModelKeys.Count > 0)
fs.TModelKeys = _tTModelKeys;
String temp = service == String.Empty ? "%" : service;
fs.Names.Add(temp.Trim());
try
{
ServiceList svlist = fs.Send();
if (svlist == null)
return null;
List<SVInfo> list = new List<SVInfo>();
foreach (ServiceInfo si in svlist.ServiceInfos)
{
SVInfo s;
s.name = si.Name;
s.key = si.ServiceKey;
s.businesskey = si.BusinessKey;
GetBusinessDetail gbd = new GetBusinessDetail();
gbd.BusinessKeys.Add(si.BusinessKey);
BusinessDetail be = gbd.Send();
s.businessname = be.BusinessEntities[0].Names[0].Text;
GetServiceDetail gsd = new GetServiceDetail();
gsd.ServiceKeys.Add(si.ServiceKey);
ServiceDetail sd = gsd.Send();
s.accesspoint = sd.BusinessServices[0].BindingTemplates[0].AccessPoint.Text;
list.Add(s);
}
return list;
}
catch (Exception)
{
return null;
throw;
}
Publish
You may review the UDDI data model picture above. There is so much information about a service, but you do not have to fill in all of these. In this demo, we assume that a BusinessEntity to publish has only one BusinessService. The access point is the link to the WSDL of the Web Service. For this operation (and delete also), you have to login with an Administrator role.
cnn = new UddiConnection();
cnn.PublishUrl = url;
cnn.Username = username;
cnn.Password = password;
cnn.AuthenticationMode = mode;
SaveBusiness sb = new SaveBusiness();
BusinessEntity be = new BusinessEntity(txbBusinessName.Text);
sb.BusinessEntities.Add(be);
BusinessService bs = new BusinessService(txbServiceName.Text);
sb.BusinessEntities[0].BusinessServices.Add(bs);
BindingTemplate bt = new BindingTemplate();
bt.AccessPoint.Text = txbAccessPoint.Text;
bt.AccessPoint.UrlType = Microsoft.Uddi.UrlType.Http;
sb.BusinessEntities[0].BusinessServices[0].BindingTemplates.Add(bt);
try
{
BusinessDetail bd = sb.Send(uddiCnn);
}
catch (UddiException ue)
{
strError = ue.Message;
}
catch (Exception ex)
{
strError = ex.Message;
}
finally
{
ProgressBarStop();
if (strError != String.Empty)
MessageBox.Show(strError);
else
MessageBox.Show("Publish service successful");
}
Delete
Similarly, we have the delete operation using the DeleteService object. This object is defined by a serviceKey which can be got from a search operation.
DeleteService delSv = new DeleteService(serviceKey);
DispositionReport dispRep = delSv.Send(ud);
Update (Access point)
In this demo, update is separated into two operations: delete the old service and publish the new one; other information can be obtained from the old one.
selectedItem = listView1.SelectedItems[0];
SVInfo serviceInfo = (SVInfo)selectedItem.Tag;
AccessPointForm epf = new AccessPointForm(serviceInfo.accesspoint);
epf.passAccessPoint = new AccessPointForm.PassAccessPoint(setAccesspoint);
if (epf.ShowDialog() == DialogResult.OK)
{
if (newAccesspoint != serviceInfo.accesspoint)
{
PerformDelete(serviceInfo.key);
ud.InquireUrl = txtURL.Text;
GetBusinessDetail gbd = new GetBusinessDetail(serviceInfo.businesskey);
BusinessDetail bd = gbd.Send(ud);
BusinessEntity be = bd.BusinessEntities[0];
SaveBusiness sb = new SaveBusiness();
sb.BusinessEntities.Add(be);
BusinessService bs = new BusinessService(serviceInfo.name);
sb.BusinessEntities[0].BusinessServices.Add(bs);
BindingTemplate bt = new BindingTemplate();
bt.AccessPoint.Text = newAccesspoint;
bt.AccessPoint.UrlType = Microsoft.Uddi.UrlType.Http;
sb.BusinessEntities[0].BusinessServices[0].BindingTemplates.Add(bt);
sb.Send(ud);
listView1.SelectedItems[0].SubItems[3].Text = newAccesspoint;
}
}
References
- Wikipedia. Universal Description Discovery and Integration. Wikipedia. [Online] http://en.wikipedia.org/wiki/Universal_Description_Discovery_and_Integration.
- Newcomer, Eric. Understanding Web Services - XML, WSDL, SOAP and UDDI. Addison-Wesley Professional; 1 edition (May 23, 2002), 2002. 978-0201750812.
- elLoco. UDDI SOA Howto. my-tech-talk.blogspot.com. [Online] http://my-tech-talk.blogspot.com/2009/01/uddi-soa-howto.html.