WSDL2UDDI v2  Locate

The BEA AquaLogic Service Registry WSDL2UDDI demo set is used to demonstrate the BEA AquaLogic Service Registry WSDL2UDDI application programming interface's capabilities and to demonstrate how to use this API. The BEA AquaLogic Service Registry WSDL2UDDI demos cover the UDDI Version 2.0.4 Specification. You will learn how to query and publish a WSDL to a UDDI registry over a SOAP interface. The BEA AquaLogic Service Registry WSDL2UDDI demo set contains following demos to assist you in learning the WSDL2UDDI client API.

PublishWSDL Demonstrates how to construct and fill the Publish_wsdl object, get the WSDL2UDDI stub for the UDDI registry, get an authToken, and perform the publish_wsdl call.

UnPublishWSDL Demonstrates how to construct and fill the Unpublish_wsdl object, get WSDL2UDDI stub for the UDDI registry, get an authToken, and perform the unpublish_wsdl call.

FindWSDL Demonstrates how to construct and fill the Find_wsdlServiceInfo object, get the WSDL2UDDI stub for the UDDI registry, get an authToken, and perform the find_wsdlServiceInfo call.

GetWSDL Demonstrates how to construct and fill the Get_wsdlServiceInfo object, get the WSDL2UDDI stub for the UDDI registry, get an authToken, and perform the get_wsdlServiceInfo 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 the registry's installation location.

To run the BEA AquaLogic Service Registry's demos, your BEA AquaLogic Service 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 necessary to configure the demos. The configuration system has two levels: global and local. The properties defined at the global level may be overwritten at 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 env.properties. This file is located in the same directory as the file run.sh ( run.bat). Local level properties for the WSDL2UDDI demos are loaded from the file:

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

Table 16. Properties Used in Demos

NameDefault ValueDescription
uddi.demos.user.john.namedemo_johnfirst user's name
uddi.demos.user.john.passworddemo_johnfirst user's password
uddi.demos.url.wsdl2uddihttp://localhost:8080/uddi/wsdl2uddithe wsdl2uddi 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 programming pattern used in all demos using the PublishWSDL demo as an example. You can find its source code in the file:

Windows: %REGISTRY_HOME%\demos\basic\wsdl2uddi\src\demo\uddi\v2\wsdl2uddi\PublishWSDL.java
UNIX: $REGISTRY_HOME/demos/basic/wsdl2uddi/src/demo/uddi/v2/wsdl2uddi/PublishWSDL.java

The main method is very short. After gathering the user's input, it gets the security stub and authorizes the user. The resulting authInfo string is a secret key passed to the Publish request, which is created and initialized in the createPublish() method.

The user's choice of WSDL is published to the selected businessEntity within the publishWSDL() method.

When successful, the WsdlDetail object is returned from the UDDI registry and printed.

The last step is to discard the authInfo string, so that no malicious user can use it to compromise another user's account.

String businessKey = UserInput.readString("Enter businessKey",
	      "d7222f66-08aa-3a6e-a299-2ed4ac785682");
String url = UserInput.readString("Enter WSDL URL",
              "http://localhost:8080/uddi/doc/demos/EmployeeList.wsdl");
System.out.println();

UDDI_Security_PortType security = getSecurityStub();
String authInfo = getAuthInfo(user, password, security);
Publish_wsdl publish = createPublish(businessKey, url, authInfo);
WsdlDetail result = publishWSDL(publish);
printWsdlDetail(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 getWsdl2uddiStub() returns the WSDL2UDDI stub of the Web service listening at URL specified by the URL_WSDL2UDDI property.

public static Wsdl2uddiApi getWsdl2uddiStub() throws SOAPException {
    // you can specify your own URL in property - uddi.demos.url.wsdl2uddi
    String url = DemoProperties.getProperty(URL_WSDL2UDDI,
                                           "http://localhost:8080/uddi/wsdl2uddi");
    System.out.print("Using WSDL2UDDI at url " + url + " ..");
    Wsdl2uddiApi inquiry = Wsdl2uddiStub.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 that it cannot be reused.

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

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

public static Publish_wsdl createPublish(String businessKey,
	                                                   String url, String authInfo)
  throws InvalidParameterException {
    System.out.println("businessKey = " + businessKey);
    System.out.println("url = " + url);

    WsdlMapping wsdlMapping = new WsdlMapping();
    wsdlMapping.setBusinessKey(businessKey);
    Wsdl wsdl = new Wsdl(url);
    WsdlDetail wsdlDetail = new WsdlDetail(wsdl, wsdlMapping);
    Publish_wsdl publish = new Publish_wsdl(wsdlDetail, authInfo);
    return publish;
}

The WSDL2UDDI API call Publish_wsdl is performed in the method publishWSDL().

public static WsdlDetail publishWSDL(Publish_wsdl save)
  throws UDDIException, SOAPException {
    Wsdl2uddiApi publishing = getWsdl2uddiStub();
    System.out.print("Save in progress ...");
    WsdlDetail wsdlDetail = publishing.publish_wsdl(save);
    System.out.println(" done");
    return wsdlDetail;
}

The returned WsdlDetail is displayed by the printWsdlDetail() method.

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

public static void printWsdlDetail(WsdlDetail wsdlDetail) {
    System.out.println();
    System.out.println(wsdlDetail.toXML());
}

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\wsdl\v2
    UNIX $REGISTRY_HOME/demos/basic/wsdl/v2

  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 demo as parameter. For example, to run the PublishWSDL demo, invoke

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

    The output of this demo will resemble the following:

    Running PublishWSDL demo...
    **********************************************************************
    ***              BEA AquaLogic Service Registry Demo - PublishWSDL              ***
    **********************************************************************
    
    Publishing WSDL where
    Enter businessKey [d7222f66-08aa-3a6e-a299-2ed4ac785682]:
    Enter WSDL URL [http://localhost:8080/uddi/inquiry/wsdl]:
           http://localhost:8080/uddi/doc/demos/EmployeeList.wsdl
    
    Using Publishing at url https://mycomp.com:8443/uddi/publishing .. done
    Logging in .. done
    businessKey = d7222f66-08aa-3a6e-a299-2ed4ac785682
    url = http://localhost:8080/uddi/doc/demos/EmployeeList.wsdl
    Using WSDL2UDDI at url https://mycomp.com:8443/uddi/wsdl2uddi .. done
    Save in progress ... done
    
    <wsdlDetail xmlns="http://systinet.com/uddi/wsdl2uddi/v2/5.0">
        <wsdl>
            <wsdlLocation>http://localhost:8080/uddi/doc/demos/EmployeeList.wsdl</wsdlLocation>
        </wsdl>
        <wsdlMapping>
            <businessKey xmlns="urn:uddi-org:api_v2">d7222f66-08aa-3a6e-a299-2ed4ac785682<
    	                     /businessKey>
            <services>
                <service name="EmployeeList" namespace="
    	                                 http://systinet.com/wsdl/demo/uddi/services/"
                  publishingMethod="rewrite">
                    <serviceKey xmlns="urn:uddi-org:api_v2">
    		                     d0a50390-af1c-11d8-b9bf-eb2d7e20b9bf</serviceKey>
                        <ports>
                            <port name="EmployeeList" publishingMethod="rewrite">
                            <bindingKey xmlns="urn:uddi-org:api_v2">
    			                  d0aca4b0-af1c-11d8-b9bf-eb2d7e20b9bf</bindingKey>
                        </port>
                    </ports>
                </service>
            </services>
            <bindings>
                <binding name="EmployeeList_binding"
    	                          namespace="http://systinet.com/wsdl/demo/uddi/services/"
                  publishingMethod="rewrite">
                    <tModelKey xmlns="urn:uddi-org:api_v2">
    		                  uuid:d07da570-af1c-11d8-b9bf-eb2d7e20b9bf</tModelKey>
                </binding>
            </bindings>
            <portTypes>
                <portType name="EmployeeList_portType"
    	                          namespace="http://systinet.com/wsdl/demo/uddi/services/"
                  publishingMethod="rewrite">
                    <tModelKey xmlns="urn:uddi-org:api_v2">
    		                         uuid:d0658990-af1c-11d8-b9bf-eb2d7e20b9bf</tModelKey>
                </portType>
            </portTypes>
        </wsdlMapping>
    </wsdlDetail>
    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.