you can search the repository for the WSDL. there's a couple of standard
schemas for publishing a web service to a UDDI repository. below is an
example of how to publish a webservice. take a look at the data
structures published. i don't currently have an example for dynamically
pulling WSDL from the repository. if you'd like to write something, i'll
be happy to add it to the jUDDI source tree.. 

here's an example using UDDI4J to register a web service in jUDDI. this
should work with any UDDI server. you'll need to adapt this to your
world a bit, but the general idea should be clear, 

also, you might take a look at
http://www.oasis-open.org/committees/uddi-spec/doc/bp/uddi-spec-tc-bp-us
ing-wsdl-v108-20021110.htm, though i've told that is a bit of date. 

cheers,
andy 

/////////////////////////////////////////////////////////////////
package webservices;

import java.net.*;
import java.util.*;

import org.uddi4j.*;
import org.uddi4j.client.*;
import org.uddi4j.datatype.*;
import org.uddi4j.datatype.binding.*;
import org.uddi4j.datatype.business.*;
import org.uddi4j.datatype.service.*;
import org.uddi4j.datatype.tmodel.*;
import org.uddi4j.response.*;
import org.uddi4j.transport.*;
import org.uddi4j.util.*;

public class UDDIPublish extends UDDIClientBase {

  protected TModelDetail animalProtocol_tModelDetail = null;
  protected BusinessDetail businessDetail = null;

  public static void main (String args[])
  {
          UDDIPublish app = new UDDIPublish();
          app.run();
          System.exit(0);
  }


  public void run()
  {
    try
    {
      init();

      /**
       * First create a common tModel to define the 'AnimalProtocol'
       */
      publish_animals_tModel();

      /**
       * Publish the business.
       */
      publish_animalBusiness();

      Vector businessEntities =
businessDetail.getBusinessEntityVector();
      BusinessEntity returnedBusinessEntity =
(BusinessEntity)(businessEntities.elementAt(0));
      System.out.println("Returned businessKey:" +
returnedBusinessEntity.getBusinessKey());

      /**
       * Create and publish the services for each implementation: CORBA,
EJB and the simple
       * Java implementation.
       *
       * The services also could have been published using one message
rather than three.
       */

      publish_animalService(returnedBusinessEntity, JANIMAL_SERVICE,
JANIMAL_WSDL_URL);
      publish_animalService(returnedBusinessEntity, EANIMAL_SERVICE,
EANIMAL_WSDL_URL);
      publish_animalService(returnedBusinessEntity, VANIMAL_SERVICE,
VANIMAL_WSDL_URL);

    }
    /**
     * Error handling is typically exception based. If an error occurs
     * (???) a DispositionReport will be generated by the UDDI server.
     * The report can be examined to discover the problem's cause.
     */
    catch( UDDIException e )
    {
      DispositionReport dr = e.getDispositionReport();
      if( dr!=null )
      {
        System.out.println("UDDIException faultCode:" + e.getFaultCode()
+
                           "\n operator:" + dr.getOperator() +
                           "\n generic:"  + dr.getGeneric() );

        Vector results = dr.getResultVector();
        for( int i=0; i<results.size(); i++ )
        {
          Result r = (Result)results.elementAt(i);
          System.out.println("\n errno:"    + r.getErrno() );
          if( r.getErrInfo()!=null )
          {
            System.out.println("\n errCode:"  +
r.getErrInfo().getErrCode() +
                               "\n errInfoText:" +
r.getErrInfo().getText());
          }
        }
      }

      e.printStackTrace();
    }
    // Catch any other exception that may occur
    catch( Exception e )
    {
      e.printStackTrace();
    }
  }

  private void publish_animalService(BusinessEntity
returnedBusinessEntity,
                                     String serviceName,
                                     String url) throws
      TransportException, UDDIException {

    BusinessService busService = new BusinessService();
    busService.setBusinessKey(returnedBusinessEntity.getBusinessKey());
    Name name = new Name(serviceName);
    busService.setDefaultName(name);
    busService.setDefaultDescriptionString("Serving the AnimalProtocol:
" + serviceName);
    /**
     * Services can contain CategoryBags, just like Businesses. We'll
     * use the same CategoryBag definition the business does
     */
    CategoryBag catBag = createCategoryBag();
    busService.setCategoryBag(catBag);

    /**
     * Services require BindingTemplates which contain the web services'
     * technical descriptions. These structures provide support
     * for determining a technical entry point. Since UDDIs main
     * purpose is to enable description and discovery of Web Service
     * information, it is the bindingTemplate that provides the most
     * interesting technical data.
     */

    BindingTemplate bindingTemplate = new BindingTemplate();

    /**
     * The template can contain any number of tModels. We'll use the
tModel
     * we defined for the AnimalProtocol, so querying programs or users
can
     * recognize our Service supports the interface. We'll also create a
     * unique tModel for this service, using the best practices
published
     * by UDDI.org, to identify the service's WSDL endpoint.
     */

    TModelInstanceDetails tModelInstanceDetails = new
TModelInstanceDetails();
    TModelInstanceInfo tModelInstanceInfo = new TModelInstanceInfo();

 
tModelInstanceInfo.setTModelKey(((TModel)animalProtocol_tModelDetail.get
TModelVector().elementAt(0)).getTModelKey());
    tModelInstanceInfo.setDefaultDescriptionString("Animal Protocol
tModel instance");
    tModelInstanceDetails.add(tModelInstanceInfo);


    tModelInstanceInfo = new TModelInstanceInfo();
 
tModelInstanceInfo.setTModelKey(((TModel)animalProtocol_tModelDetail.get
TModelVector().elementAt(0)).getTModelKey());

    /**
     * This creates the unique, well-defined tModel representing the
service's WSDL
     */
    TModelDetail tmodelDetail = publishWSDL_tModel(url);
    tModelInstanceInfo = new TModelInstanceInfo();
 
tModelInstanceInfo.setTModelKey(((TModel)tmodelDetail.getTModelVector().
elementAt(0)).getTModelKey());
    tModelInstanceInfo.setDefaultDescriptionString("Animal Service
tModel instance");
    tModelInstanceDetails.add(tModelInstanceInfo);

    /**
     * Associate the set of tModels with the Service's BindingTemplate
     */
    bindingTemplate.setTModelInstanceDetails(tModelInstanceDetails);

    /**
     * The binding template needs an [ accessPoint | hostRedirector ]
     */
    AccessPoint animalAccessPoint =
createAccessPoint(url.substring(0,url.lastIndexOf("?")));
    bindingTemplate.setAccessPoint(animalAccessPoint);
    BindingTemplates bindingTemplates = new BindingTemplates();

    bindingTemplate.setDefaultDescriptionString("SOAP Binding");
    bindingTemplates.add(bindingTemplate);

    busService.setBindingTemplates(bindingTemplates);

    // save the service
    java.util.Vector servicesVector = new Vector();
    servicesVector.add(busService);
    proxy.save_service(token.getAuthInfoString(),servicesVector);
  }

  /** The BusinessDetail returned by the UDDI server
   * includes information necessary to publish the services offered by
   * the business, including the UUID generated by the UDDI server
   * uniquely identifying the business.
   */
  private void publish_animalBusiness() throws
      TransportException, UDDIException {
    Vector entities = new Vector();

    /**
     * Create a new business entity using required elements constructor
     * BusinessKey must be "" to save a new business. The UDDI registry
     * automatically generates a UUID representing the business.
     */
    BusinessEntity be = new BusinessEntity("", ANIMAL_BUSINESS);

    /**
     * Contact information is optional
     */
    Contact busContact = new Contact("Olli A. Menendez");
    busContact.setDefaultDescriptionString("Virtual Zookeeper");

    Email email = new Email();
    email.setText("[EMAIL PROTECTED]");
    Vector emailVector = new Vector();
    emailVector.add(email);
    busContact.setEmailVector(emailVector);

    Contacts contactList = new Contacts();
    contactList.add(busContact);

    busContact = new Contact("Steve Irwin");
    busContact.setDefaultDescriptionString("Consulting Crocidile
Hunter");
    email = new Email("[EMAIL PROTECTED]");
    emailVector = new Vector();
    emailVector.add(email);
    busContact.setEmailVector(emailVector);

    contactList.add(busContact);

    be.setContacts(contactList);
    be.setDefaultDescriptionString("The Number One Supplier of Animal
Services on the Web");

    /**
     * The identifierBag element Busineses to publish information about
common
     * forms of identification such as D-U-N-S numbers, tax identifiers,
etc.
     * Including data of this sort is optional.
     *
     * The identifierBag element can also be used with other UDDI
specified datastructures
     * and messages.
     */

    IdentifierBag idBag = createIdentifierBag();
    be.setIdentifierBag(idBag);

    /**
     * The categoryBag element allows Business to be categorized
according to any of several
     * available taxonomy based classification schemes. Operator Sites
     * automatically provide validated categorization support for three
taxonomies
     * that cover industry codes (via NAICS), product and
     * service classifications (via UNSPC) and geography (via ISO 3166).
     *
     * This data is optional, and can be associated with other UDDI
datastructures
     * and UDDI messages.
     */

    CategoryBag catBag = createCategoryBag();
    be.setCategoryBag(catBag);

    entities.addElement(be);

    /**
     * publish the business
     */
    businessDetail =
proxy.save_business(token.getAuthInfoString(),entities);

    Vector businessEntities = businessDetail.getBusinessEntityVector();
    BusinessEntity returnedBusinessEntity =
(BusinessEntity)(businessEntities.elementAt(0));
    System.out.println("Returned businessKey:" +
returnedBusinessEntity.getBusinessKey());
  }

  private CategoryBag createCategoryBag() {
    CategoryBag catBag = new CategoryBag();
    KeyedReference kr = new KeyedReference(TModel.NAICS_TMODEL_KEY,
"<FAKE NAICS NUMBER>");
    catBag.add(kr);
    return catBag;
  }

  private IdentifierBag createIdentifierBag() {
    IdentifierBag idBag = new IdentifierBag();
    KeyedReference kr = new KeyedReference(TModel.D_U_N_S_TMODEL_KEY ,
"<FAKE DUNS KEY>");
    idBag.add(kr);
    return idBag;
  }

  /**
   * Creates a tModel, identifying WSDL endpoint. This is the
   * best practices model for registering a WSDL describing a business
service.
   * Applications searching registries for WSDL will be searching
registries for
   * this datastructure.
   *
   * The datastructure contains a endpoint for the Service's WSDL
document, so
   * each service will need a unique tModel.
   *
   * Best Practices are outlined in the document
   *
http://www.oasis-open.org/committees/uddi-spec/doc/bp/uddi-spec-tc-bp-us
ing-wsdl-v108-20021110.htm
   *
   */
  private TModelDetail publishWSDL_tModel(String url)
      throws TransportException, UDDIException
  {
    TModel animalWSDL_tModel = new TModel();
    /**
     * UDDI best practices recommend a specific format for the
OverviewDocument
     * for this tModel.
     */
    OverviewDoc animalWSDL_overviewDoc = new OverviewDoc();
    animalWSDL_overviewDoc.setDefaultDescriptionString("WSDL source
document");
    animalWSDL_overviewDoc.setOverviewURL(url);
    animalWSDL_tModel.setOverviewDoc(animalWSDL_overviewDoc);

    KeyedReference kr = new KeyedReference("uuid-org:types","wsdlSpec");
    kr.setTModelKey(TModel.TYPES_TMODEL_KEY);
    CategoryBag catBag = new CategoryBag();
    catBag.add(kr);
    animalWSDL_tModel.setCategoryBag(catBag);

    animalWSDL_tModel.setName(ANIMAL_SERVICE_NAME);
    animalWSDL_tModel.setDefaultDescriptionString("WSDL description of
Animal protocol interface");
    java.util.Vector tModelVector = new Vector();
    tModelVector.add(animalWSDL_tModel);
    TModelDetail animal_tModelDetail =
proxy.save_tModel(token.getAuthInfoString(), tModelVector);
    return animal_tModelDetail;
  }

  /**
   * This creates a tModel with a UUID identiying the uniquely
'AnimalProtocol'.
   * The UUID can then be used to publish services supporting the
   * 'AnimalProtocol'. The name or the UUID key can be used by clients
looking for
   * support of a particular protocol.
   */
  private boolean publish_animals_tModel()
  {
    TModel animal_tModel =  new TModel();
    animal_tModel.setName(ANIMAL_PROTOCOL_NAME);
    animal_tModel.setDefaultDescriptionString("An Interface to allow
animals to " +
                                              "programatically talk,
walk and sleep");

    /**
     * An OverviewDoc element allows you to register links to more
complete information,
     * like expected behavior, design goals, etc., describing your
registered service.
     * This might be used to provide engineers with manual pages, etc.
We create a sample
     * url below.
     *
     * Unlike the WSDL tModel defined above, there is no convention
governing this
     * tModel's OverviewDoc.
     */
    OverviewDoc overviewDoc = new OverviewDoc();
    overviewDoc.setDefaultDescriptionString("Animal Protocol
Documentation and IDL");
    overviewDoc.setOverviewURL("<url for documentation and IDL>");

    java.util.Vector tModelVector = new Vector();
    tModelVector.add(animal_tModel);
    try {
      animalProtocol_tModelDetail =
proxy.save_tModel(token.getAuthInfoString(),
          tModelVector);
    }
    catch (TransportException ex) {
      return false;
    }
    catch (UDDIException ex) {
      return false;
    }
    return true;
  }

  private AccessPoint createAccessPoint(String url) {
    AccessPoint animalAccessPoint = new AccessPoint();
    animalAccessPoint.setURLType("http");
    animalAccessPoint.setText(url);
    return animalAccessPoint;
  }
} 

> -----Original Message-----
> From: Vasiliki Pouli [mailto:[EMAIL PROTECTED] 
> Sent: Tuesday, May 24, 2005 12:56 AM
> To: [email protected]
> Subject: receive WSDL
> 
> Hello, I would like to ask if you know how to receive from 
> jUDDI the WSDL of 
> a web service programmatically?
> 
> 
> 

Reply via email to