UDDI & Dynamic Web Service Binding
by Peter Lacey


Listing One 

<tModel authorizedName="..." operator="..." 
 tModelKey="uuid:c01dd3c0-f83e-11d7-bbaa-b8a03c50a862">
    <name>http://soapinterop.org/WSDLInteropTestDocLit</name>
    <description xml:lang="en">
        SOAPBuilders, Round 3, Group D, InteropTestDocLitParameters
    </description>
    <overviewDoc>
        <overviewURL>
            http://www.whitemesa.com/r3/InteropTestDocLitParameters.wsdl
        </overviewURL>
    </overviewDoc>
    <categoryBag>
        <keyedReference keyName="Specification for a Web Service 
                                                          described in WSDL"
         keyValue="wsdlSpec" 
                    tModelKey= "uuid:c1acf26d-9672-4404-9d70-39b756e62ab4"/>
    </categoryBag>
</tModel>


Listing Two

<businessEntity authorizedName="..." 
  businessKey="fe3f5b90-f831-11d7-bba8-b8a03c50a862" operator="...">
    <discoveryURLs>
        <discoveryURL useType="businessEntity">
            http://uddiservername/uddi/web?businessKey=
                                         fe3f5b90-f831-11d7-bba8-b8a03c50a862
        </discoveryURL>
    </discoveryURLs>
    <name xml:lang="en">Dynavoke</name>
    <description xml:lang="en">Doctor Dobbs Demo Company</description>
        <businessServices>
            <businessService authorizedName="..." 
              businessKey="fe3f5b90-f831-11d7-bba8-b8a03c50a862" 
              serviceKey="3d21f530-f840-11d7-bbaa-b8a03c50a862">
            <name xml:lang="en">InteropTestDocLitParameters</name>
            <bindingTemplates>
                <bindingTemplate authorizedName="..." 
                  bindingKey="05e3b210-f841-11d7-bbaa-b8a03c50a862" 
                  serviceKey="3d21f530-f840-11d7-bbaa-b8a03c50a862">
                    <description xml:lang="en">Sun access point</description>
                    <accessPoint URLType="http">
                      http://soapinterop.java.sun.com:
                                             80/round3/groupd/doclitparams
                    </accessPoint>
                    <tModelInstanceDetails>
                        <tModelInstanceInfo 
                          tModelKey=
                              "uuid:c01dd3c0-f83e-11d7-bbaa-b8a03c50a862">
                        <instanceDetails>
                            <overviewDoc>
                                <overviewURL/>
                            </overviewDoc>
                        </instanceDetails>
                        </tModelInstanceInfo>
                    </tModelInstanceDetails>
                </bindingTemplate>
                <bindingTemplate authorizedName="..." 
                  bindingKey="b6c83b10-f840-11d7-bbaa-b8a03c50a862" 
                  serviceKey="3d21f530-f840-11d7-bbaa-b8a03c50a862">
                    <description xml:lang=
                                    "en">Systinet access point</description>
       <accessPoint URLType="http">
                      http://soap.systinet.net/ws/
                                         InteropTestDocLitParametersService/
                    </accessPoint>
                    <tModelInstanceDetails>
                        <tModelInstanceInfo 
                          tModelKey="uuid:c01dd3c0-f83e-11d7-
                                                         bbaa-b8a03c50a862">
                            <instanceDetails>
                                <overviewDoc>
                                    <overviewURL/>
                                </overviewDoc>
                            </instanceDetails>
                        </tModelInstanceInfo>
                    </tModelInstanceDetails>
                </bindingTemplate>
            </bindingTemplates>
        </businessService>
    </businessServices>
</businessEntity>


Listing Three

package com.systinet.uddi.bindingDemo;
import org.systinet.wasp.webservice.Registry;
import com.systinet.uddi.bindingDemo.iface.WSDLInteropTestDocLitPortType;
import com.systinet.uddi.bindingDemo.iface.struct.EchoString;
import com.systinet.uddi.bindingDemo.iface.struct.EchoStringResponse;

public class SBInteropDocLit extends Object {
    public static void main (String args[]) throws Exception {
        // Hard coding address of WSDL.  Relying on WSDL <service> 
        // element for service address
    String wsdlURI = "http://soap.systinet.net/ws/
                                   InteropTestDocLitParametersService/wsdl";
        // Create local proxy of the remote service        
        WSDLInteropTestDocLitPortType WSDLInteropService = 
          (WSDLInteropTestDocLitPortType) Registry.lookup(wsdlURI, 
          WSDLInteropTestDocLitPortType.class);
        // Create class to send to service
        EchoString stringParam = new EchoString();
        stringParam.param0 = "UDDI";
        // Call service
        System.out.println("Sending string \"" + stringParam.param0 + "\"");
        EchoStringResponse stringResponse = 
                                  WSDLInteropService.echoString(stringParam);
        System.out.println("Received \"" + 
                                   stringResponse._return_ + "\" in return");
    }
}

Listing Four

package com.systinet.uddi.bindingDemo;
import org.idoox.uddi.UDDIException;
import org.idoox.uddi.client.api.v2.UDDIProxy;
import org.idoox.uddi.client.api.v2.response.ServiceInfo;
import org.idoox.uddi.client.structure.v2.binding.BindingTemplate;
import org.idoox.uddi.client.structure.v2.service.ServiceKey;
import org.idoox.uddi.client.structure.v2.tmodel.TModelKey;

import org.systinet.wasp.webservice.ServiceClient;
import org.systinet.wasp.webservice.Registry;
import org.systinet.wasp.webservice.LookupException;

public class UddiRegistry {
    UDDIProxy uddiProxy;
    public UddiRegistry(String inquiryPort) {
       // Instantiate a local proxy of the UDDI server
       uddiProxy = new UDDIProxy(inquiryPort);
    }
    public Object lookup (TModelKey tModelKey, Class proxyInterface) 
      throws UDDIException, LookupException {
        // Ideally, the access point retrieved in some previous search should 
        // be cached and indexed by the tModelKey. You should try to bind to 
        // this cached instance first to avoid the expense of a UDDI lookup. 
        // This step is skipped here
        // Get WSDL from tModel
        String wsdlURI = 
          uddiProxy.get_tModelOverviewURL(tModelKey.getValue()).getValue();   
        System.out.println("Found Service 
                                    Definition (WSDL) URI at: " + wsdlURI);
        // Get all services that have binding templates associated with tModel
        ServiceInfo[] serviceInfoArray = 
         uddiProxy.find_service(null, null, null, tModelKey.getValue(), null);
        String serviceKey = serviceInfoArray[0].getServiceKey().getValue();
        System.out.println("Found Service Key: " + serviceKey);
        // Get all binding templates associated with service and tModel
        BindingTemplate[] bindingTemplateArray = 
          uddiProxy.find_binding(serviceKey, tModelKey.getValue(), null);
        System.out.println("Found " + bindingTemplateArray.length + 
                                                        " implementations");
        ServiceClient serviceClient = ServiceClient.create(wsdlURI);
        // for each binding template, get the access point and try to bind
        for (int i=0; i < bindingTemplateArray.length; i++) {
            String accessPoint = 
                         bindingTemplateArray[i].getAccessPoint().getValue();
            serviceClient.setServiceURL(accessPoint);
            System.out.println("Attempting to bind to access 
                                                   point at " + accessPoint);
            try {
                Object ServiceProxy = 
                                   serviceClient.createProxy(proxyInterface);
                System.out.println("Success");
                return ServiceProxy;
            } catch (LookupException le) {
                System.out.println("Unable to bind to 
                                                 service at " + accessPoint);
            }   
        }
        throw new LookupException();
    }
}

Listing Five

package com.systinet.uddi.bindingDemo;
import com.systinet.uddi.bindingDemo.iface.WSDLInteropTestDocLitPortType;
import com.systinet.uddi.bindingDemo.iface.struct.EchoString;
import com.systinet.uddi.bindingDemo.iface.struct.EchoStringResponse;

import org.idoox.uddi.client.structure.v2.tmodel.TModelKey;
public class DynamicSBInteropDocLit {
    public static void main(String args[]) throws Exception {
        // Well known tModel Key of the InteropTestDocLitParameters WSDL
        TModelKey tModelKey = 
                new TModelKey("uuid:c01dd3c0-f83e-11d7-bbaa-b8a03c50a862");
        // Instantiate a new UddiRegistry bound to the inquiry portof a local 
        // WASP UDDI server
        UddiRegistry uddiRegistry = 
                      new UddiRegistry("http://localhost:8080/uddi/inquiry");
        // Retrieve a service proxy for one of the possibly many 
        // services that implement the InteropTestDocLitParameters interface
        WSDLInteropTestDocLitPortType WSDLInteropService = 
          (WSDLInteropTestDocLitPortType) uddiRegistry.lookup(tModelKey, 
          WSDLInteropTestDocLitPortType.class);
        // Create class to send to service
        EchoString stringParam = new EchoString();
        stringParam.param0 = "UDDI";
        // Call service
        System.out.println("\nSending string \"" + stringParam.param0 +"\"");
        EchoStringResponse stringResponse = 
                                  WSDLInteropService.echoString(stringParam);
        System.out.println("Received \"" + 
                                   stringResponse._return_ + "\" in return");
    }
}

Listing Six

Found Service Definition (WSDL) URI at: 
http://www.whitemesa.com/r3/InteropTestD
ocLitParameters.wsdl
Found Service Key: 3d21f530-f840-11d7-bbaa-b8a03c50a862
Found 2 implementations
Attempting to bind to access point at 
http://soap.systinet.net/ws/InteropTestDoc
LitParametersService/
Success

Sending string "UDDI"
Received "UDDI" in return





4


