Publishing v3  Locate

The BEA AquaLogic Service Registry basic publishing demo set demonstrates the BEA AquaLogic Service Registry application programming interface's capabilities and teaches how to use this API to perform basic publishing calls to a UDDI registry.

The BEA AquaLogic Service Registry basic publishing demos cover the publication aspect of the UDDI Version 3 Specification. You will learn, how to use the BEA AquaLogic Service Registry client API to publish information to a UDDI registry over a SOAP interface. There is one demo for each UDDI call, from add_publisherAssertion through get_registeredInfo to save_business.

The BEA AquaLogic Service Registry basic publishing demo set contains the following demos. They will assist you in learning the BEA AquaLogic Service Registry client API.

AddAssertion Demonstrates how to construct and fill the Add_publisherAssertion object, get a Publishing stub for the UDDI registry, get an authToken, and perform the add_publisherAssertion call.

DeleteAssertion Demonstrates how to construct and fill the Delete_publisherAssertion object, get a Publishing stub for the UDDI registry, get an authToken, and perform the delete_publisherAssertion call.

DeleteBinding Demonstrates how to construct and fill the Delete_binding object, get a Publishing stub for the UDDI registry, get an authToken, and perform the delete_binding call.

DeleteBusiness Demonstrates how to construct and fill the Delete_business object, get Publishing stub for the UDDI registry, get an authToken, and perform the delete_business call.

DeleteService Demonstrates how to construct and fill the Delete_service object, get Publishing stub for the UDDI registry, get an authToken, and perform the delete_service call.

DeleteTModel Demonstrates how to construct and fill the Delete_tModel object, get a Publishing stub for the UDDI registry, get an authToken, and perform the delete_tModel call.

GetAssertionStatusReport Demonstrates how to construct and fill the Get_assertionStatusReport object, get a Publishing stub for the UDDI registry, get an authToken, and perform the get_assertionStatusReport call.

GetPublisherAssertions Demonstrates how to construct and fill the Get_publisherAssertions object, get a Publishing stub for the UDDI registry, get an authToken, and perform the get_publisherAssertions call.

GetRegisteredInfo Demonstrates how to construct and fill the Get_registeredInfo object, get a Publishing stub for the UDDI registry, get an authToken, and perform the get_registeredInfo call.

SaveBinding Demonstrates how to construct and fill the Save_binding object, get a Publishing stub for the UDDI registry, get an authToken, and perform the save_binding call.

SaveBusiness Demonstrates how to construct and fill the Save_business object, get a Publishing stub for the UDDI registry, get an authToken, and perform the save_business call.

SaveService Demonstrates how to construct and fill the Save_service object, get a Publishing stub for the UDDI registry, get an authToken, and perform the save_service call.

SaveTModel Demonstrates how to construct and fill the Save_tModel object, get a Publishing stub for the UDDI registry, get an authToken, and perform the save_tModel call.

SetAssertions Demonstrates how to construct and fill the Set_publisherAssertions object, get a Publishing stub for the UDDI registry, get an authToken, and perform the set_publisherAssertions call.

Prerequisites and Preparatory Steps: Code  Locate

We expect that you have already installed the BEA AquaLogic Service Registry and set the REGISTRY_HOME environment variable to its installation location.

To run the BEA AquaLogic Service Registry's demos, your UDDI registry must be running. To start the registry, execute the serverstart script:

Windows: %REGISTRY_HOME%\bin\serverstart.bat
UNIX: $REGISTRY_HOME/bin/serverstart.sh

It is neccessary to configure the demos. The configuration system has two levels: global and local. The properties defined at the global level may be overwritten at the local level. The global properties are located in the file:

Windows: %REGISTRY_HOME%\demos\env.properties
UNIX: $REGISTRY_HOME/demos/env.properties

The values set during the installation of the BEA AquaLogic Service Registry work out of the box, and their modification affects all demos. If you need to redefine the value of some property for a single demo (that is, at the local level), edit the file env.properties in the directory where run.sh(run.bat) is located. Local level properties for the Basic/Inquiry demos are loaded from the file:

Windows: %REGISTRY_HOME%\demos\basic\publishing\v3\env.properties
UNIX: $REGISTRY_HOME/demos/basic/publishing/v3/env.properties

Table 6. Properties Used in the Demos

NameDefault ValueDescription
uddi.demos.user.john.namedemo_johnFirst user's name
uddi.demos.user.john.passworddemo_johnFirst user's password
uddi.demos.user.jane.namedemo_janeSecond user's name
uddi.demos.user.jane.passworddemo_janeSecond user's password
uddi.demos.url.publishinghttp://localhost:8080/uddi/publishingThe publication Web service port URL
uddi.demos.url.securityhttp://localhost:8080/uddi/securityThe security web service port URL
Presentation and Functional Presentation  Locate

This section describes the programming pattern used in all demos using the SaveBusiness demo as an example. You can find this demo's source code in the file:

Windows: %REGISTRY_HOME%\demos\basic\publishing\src\demo\uddi\v3\publishing\SaveBusiness.java
UNIX: $REGISTRY_HOME/demos/basic/publishing/src/demo/uddi/v3/publishing/SaveBusiness.java

The main method is easy to understand. First it gathers the user's input: an optional publisher-assigned businessKey, then variable long array of business entity names with their language codes, and a description of the business.

The next step is to get the security stub and authorize the user. The resulting authInfo string is a secret key passed in all requests.

Next, the Save_business object is created, filled, and passed to the saveBusiness method as a parameter.

When successful, the BusinessDetail object is returned from the UDDI registry and printed. The last step is to discard the authInfo string, so no malicious user can use it to compromise a user's account.

String businessKey = UserInput.readString("Enter (optional) businessKey", "");
int count = UserInput.readInt("Enter count of names", 1);
String[] names = new String[count];
String[] languageCodes = new String[count];
for (int i = 0; i < count; i++) {
    String tmp = UserInput.readString("Enter language code", "");
    languageCodes[i] = (tmp.length() > 0) ? tmp : null;
    names[i] = UserInput.readString("Enter name in language " + tmp, "Marketing");
}
String description = UserInput.readString("Enter description", "Saved by SaveBusiness demo");
System.out.println();

UDDI_Security_PortType security = getSecurityStub();
String authInfo = getAuthInfo(user, password, security);
Save_business save = createSaveBusiness(businessKey, names, languageCodes, description, authInfo);
BusinessDetail result = saveBusiness(save);
printBusinessDetail(result);
discardAuthInfo(authInfo, security);

The helper method, getSecurityStub() returns the UDDI Security stub of the web service listening at the URL specified by the URL_SECURITY property.

public static UDDI_Security_PortType getSecurityStub()
 throws SOAPException {
    // you can specify your own URL in property - uddi.demos.url.security
    String url = DemoProperties.getProperty(URL_SECURITY, "http://localhost:8080/uddi/security");
    System.out.print("Using Security at url " + url + " ..");
    UDDI_Security_PortType security = UDDISecurityStub.getInstance(url);
    System.out.println(" done");
    return security;
}

Similarly, the helper method getPublishingStub() returns the UDDI Publication stub of the web service listening at the URL specified by the URL_PUBLISHING property.

public static UDDI_Publication_PortType getPublishingStub()
 throws SOAPException {
    // you can specify your own URL in property - uddi.demos.url.publishing
    String url = DemoProperties.getProperty(URL_PUBLISHING, "http://localhost:8080/uddi/publishing");
    System.out.print("Using Publishing at url " + url + " ..");
    UDDI_Publication_PortType inquiry = UDDIPublishStub.getInstance(url);
    System.out.println(" done");
    return inquiry;
}

The getAuthInfo() method is used to authorize the user against the UDDI registry and to get the secret authInfo key.

public static String getAuthInfo(String userName, String password, UDDI_Security_PortType security)
  throws InvalidParameterException, UDDIException {
    System.out.print("Logging in ..");
    AuthToken authToken = security.get_authToken(new Get_authToken(userName, password));
    System.out.println(" done");
    return authToken.getAuthInfo();
}

The discardAuthInfo() method invalidates the secret authInfo key, so it cannot be used anymore.

public static void discardAuthInfo(String authInfo, UDDI_Security_PortType security)
  throws InvalidParameterException, UDDIException {
    System.out.print("Logging out ..");
    security.discard_authToken(new Discard_authToken(authInfo));
    System.out.println(" done");
}

The createSaveBusiness() method is used to create a new instance of the Save_business class and initialize it with values from parameters:

public static Save_business createSaveBusiness(String businessKey, String[] names,
  String[] nameLangCodes, String description, String authInfo)
  throws InvalidParameterException {
    System.out.println("businessKey = " + businessKey);
    for (int i = 0; i < names.length; i++) {
        System.out.println("lang = " + nameLangCodes[i] + ", name = " + names[i]);
    }
    System.out.println("description = " + description);

    BusinessEntity businessEntity = new BusinessEntity();
    if (businessKey!=null && businessKey.length()>0)
        businessEntity.setBusinessKey(businessKey);
    for (int i = 0; i < names.length; i++) {
        if (nameLangCodes[i] == null) {
            businessEntity.addName(new Name(names[i]));
        } else {
            businessEntity.addName(new Name(names[i], nameLangCodes[i]));
        }
    }
    businessEntity.addDescription(new Description(description));

    Save_business save = new Save_business();
    save.addBusinessEntity(businessEntity);
    save.setAuthInfo(authInfo);
    return save;
}

The UDDI API call save_business is performed in the method saveBusiness():

public static BusinessDetail saveBusiness(Save_business save)
  throws UDDIException, SOAPException {
    UDDI_Publication_PortType publishing = getPublishingStub();
    System.out.print("Save in progress ...");
    BusinessDetail businessDetail = publishing.save_business(save);
    System.out.println(" done");
    return businessDetail;
}

The saved businessEntity is displayed by the printBusinessDetail() method. One interesting aspect of the BEA AquaLogic Service Registry client API is that each UDDIObject contains the toXML(), which returns a human-readable formatted listing of the XML representation.

public static void printBusinessDetail(BusinessDetail businessDetail) {
    System.out.println();
    BusinessEntityArrayList businessEntityArrayList = businessDetail.getBusinessEntityArrayList();
    int position = 1;
    for (Iterator iterator = businessEntityArrayList.iterator(); iterator.hasNext();) {
        BusinessEntity entity = (BusinessEntity) iterator.next();
        System.out.println("Business " + position + " : " + entity.getBusinessKey());
        System.out.println(entity.toXML());
        System.out.println();
        System.out.println("********************************************************");
        position++;
    }
}
Building and Running Demos  Locate

This section shows how to build and run the BEA AquaLogic Service Registry Basic Publishing demo set. Let's continue with our SaveBusiness demo.

  1. Be sure that the demos are properly configured and the BEA AquaLogic Service Registry is up and running.

  2. Change your working directory to:

    Windows:%REGISTRY_HOME%\demos\basic\publishing\v3
    UNIX:$REGISTRY_HOME/demos/basic/publishing/v3

  3. Build all demos using:

    Windows: run.bat make
    UNIX: ./run.sh make

    [Note]Note

    When compiling demos on Windows platforms, you may see the following text:

    A subdirectory or file ..\..\common\.\build\classes already exists.

    This is expected and does not indicate a problem.

  4. To get list of all available demos, run

    Windows: run.bat help
    UNIX: ./run.sh help

  5. The selected demo can be executed via the run command using the name of the demo as a parameter. For example to run the SaveBusiness demo, invoke

    Windows: run.bat SaveBusiness
    UNIX: ./run.sh SaveBusiness

    The output of this demo will resemble the following:

    **************************************************************************
    ***    Systinet Registry Demo - SaveBusiness   ***
    **************************************************************************
    
    Saving business entity where
    Enter (optional) businessKey []: uddi:systinet.com:demo:marketing
    Enter count of names [1]: 1
    Enter language code []:
    Enter name in language  [Marketing]:
    Enter description [Saved by SaveBusiness demo]: Marketing department
    
    Using Security at url http://localhost:8080/uddi/security .. done
    Logging in .. done
    businessKey = uddi:systinet.com:demo:marketing
    lang = null, name = Marketing
    description = Marketing department
    Using Publishing at url http://localhost:8080/uddi/publishing .. done
    Save in progress ... done
    
    Business 1 : uddi:systinet.com:demo:marketing
    
    <businessEntity businessKey="uddi:systinet.com:demo:marketing" xmlns="urn:uddi-org:api_v3">
      <name>Marketing</name>
      <description>Marketing department</description>
    </businessEntity>
    
    ********************************************************
    Logging out .. done
  6. To rebuild demos, execute run.bat clean (./run.sh clean) to delete the classes directory and run.bat make (./run.sh make) to rebuild the demo classes.