Click here to Skip to main content
15,884,298 members
Articles / Programming Languages / C#
Article

Publish a WSDL to a UDDI Server

Rate me:
Please Sign up or sign in to vote.
0.00/5 (No votes)
16 Mar 2009CPOL2 min read 31.2K   752   10   2
This article describes the basic steps to interact with a UDDI server.

Sample Image

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.

C#
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.

C#
cnn = new UddiConnection();
cnn.PublishUrl = url;
cnn.Username = username;
cnn.Password = password;
cnn.AuthenticationMode = mode;  
// Create a business entry.
SaveBusiness sb = new SaveBusiness();
BusinessEntity be = new BusinessEntity(txbBusinessName.Text);
sb.BusinessEntities.Add(be);

//Create a business service.
BusinessService bs = new BusinessService(txbServiceName.Text);
sb.BusinessEntities[0].BusinessServices.Add(bs);

//Create a binding template.
BindingTemplate bt = new BindingTemplate();
bt.AccessPoint.Text = txbAccessPoint.Text;
bt.AccessPoint.UrlType = Microsoft.Uddi.UrlType.Http;
sb.BusinessEntities[0].BusinessServices[0].BindingTemplates.Add(bt);

// Send the business entry data to the UDDI server.
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.

C#
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.

C#
selectedItem = listView1.SelectedItems[0];
SVInfo serviceInfo = (SVInfo)selectedItem.Tag;
// Get new accesspoint
AccessPointForm epf = new AccessPointForm(serviceInfo.accesspoint);
epf.passAccessPoint = new AccessPointForm.PassAccessPoint(setAccesspoint);
if (epf.ShowDialog() == DialogResult.OK)
{
    
    if (newAccesspoint != serviceInfo.accesspoint)
    {
        //~Get new 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

  1. Wikipedia. Universal Description Discovery and Integration. Wikipedia. [Online] http://en.wikipedia.org/wiki/Universal_Description_Discovery_and_Integration.
  2. Newcomer, Eric. Understanding Web Services - XML, WSDL, SOAP and UDDI. Addison-Wesley Professional; 1 edition (May 23, 2002), 2002. 978-0201750812.
  3. elLoco. UDDI SOA Howto. my-tech-talk.blogspot.com. [Online] http://my-tech-talk.blogspot.com/2009/01/uddi-soa-howto.html.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
GeneralUnable to execute this project Pin
prati.g@gmail.com12-Apr-10 17:07
prati.g@gmail.com12-Apr-10 17:07 
Hello ,

I need to connect to "http://uddi.xmethods.net/inquire" and https://uddi.xmethods.net/publish and browse the webservices in dotnet
This project code seems to browse UDDI and display BusinessName, ServiceKey and Endpoint but the project doesn't execute.
I get the following error--
"Cross-thread operation not valid: Control '' accessed from a thread other than the thread it was created on"
Can anybody kindly provide the working link for this project

Thanks in advance,
Prat
Generalhelp needed Pin
Adace Gavril Marius22-May-09 2:43
Adace Gavril Marius22-May-09 2:43 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.