Accessing Backend APIs  Locate

This section will show you how to integrate BEA AquaLogic Service Registry with your application. Your application can be deployed as a servlet to the same context of the application server as the registry. In this case, the servlet of your application can access instances of BEA AquaLogic Service Registry APIs as shown in Figure 5.

Figure 5. Accessing Backend Registry APIs - Architecture View

Accessing Backend Registry APIs - Architecture View

The sequence of steps that precedes access to the BEA AquaLogic Service Registry API is shown in Figure 6.

  1. BEA AquaLogic Service Registry's API implementations are registered in the WASP context during the boot of the registry.

  2. The example servlet deployed in the WASP context calls the getInstance() method with the required UDDI Registry interface as a parameter to obtain a reference of the interface implementation.

  3. The example servlet can call the API methods of BEA AquaLogic Service Registry.

Figure 6. Accessing Backend Registry APIs - Sequence Diagram

Accessing Backend Registry APIs - Sequence Diagram
[Note]Note

We assume BEA AquaLogic Service Registry is ported to WebLogic in the registry context using registry.war. For more information on porting BEA AquaLogic Service Registry to WebLogic, please see WebLogic in the Installation Guide.

Follow these steps to create and deploy the example servlet:

  1. Create the example servlet class shown in Example 5.

    Compile the ExampeServlet.java using:

    javac -classpath %REGISTRY_HOME%\dist\uddiclient_api_v3.jar;
     %REGISTRY_HOME%\dist\uddiclient_core.jar;
     %REGISTRY_HOME%\lib\wasp.jar;
     %REGISTRY_HOME%\lib\servlet.jar ExampleServlet.java
                    

  2. Update the web application archive file registry.war

    1. Copy ExampleServlet.class to the directory Web-inf\classes\com\systinet\example\servlet inside the registry.war.

    2. Add the example servlet definition to Web-inf\web.xml inside the registry.war as shown in Example 6.

    3. From the directory REGISTRY_HOME\dist, copy uddiclient_api_v3.jar and uddiclient_core.jar files to Web-inf\lib inside the registry.war

  3. Redeploy the registry.war to the WebLogic server.

The example servlet will be available at http://localhost:7001/registry/myexamples.

You can test it as shown at Figure 7.

Figure 7. Example Servlet Output

Example Servlet Output

Example 5.  ExampleServet.java

package com.systinet.example.servlet;

import org.idoox.wasp.Context;
import org.idoox.wasp.InstanceNotFoundException;
import org.systinet.uddi.InvalidParameterException;
import org.systinet.uddi.client.v3.UDDIException;
import org.systinet.uddi.client.v3.UDDI_Inquiry_PortType;
import org.systinet.uddi.client.v3.struct.*;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Iterator;

public class ExampleServlet extends HttpServlet {

    public void doGet(HttpServletRequest request, HttpServletResponse response) 
        throws IOException, ServletException {
        try {
            String searchedBusiness = request.getParameter("sbusiness");
            if (searchedBusiness == null) searchedBusiness = "";
            response.setContentType("text/html");
            PrintWriter out = response.getWriter();
            out.println("<HTML>");
            out.println("<HEAD>");
            out.println("<H1>Example Servlet Integration With Registry</H1>");
            out.println("<P>Enter the business name you wish to search");
            out.println("<FORM METHOD=GET ACTION=/registry/myexamples/>");
            out.println("<INPUT NAME=sbusiness SIZE=20 VALUE=" + searchedBusiness + ">");
            out.println("<INPUT TYPE=SUBMIT VALUE=Search>");
            out.println("</FORM>");

            // get UDDI API V3 Inquiry implementation
            UDDI_Inquiry_PortType inquiry = 
                (UDDI_Inquiry_PortType) Context.getInstance(UDDI_Inquiry_PortType.class);

            // prepare find_business call
            Find_business find_business = new Find_business();
            if (searchedBusiness.length() > 0) {
                find_business.addName(new Name(searchedBusiness));
                out.println("<P>Searching business :" + searchedBusiness);
                // call find_business
                BusinessList businessList = inquiry.find_business(find_business);
                // process the result
                BusinessInfoArrayList businessInfoArrayList 
                    = businessList.getBusinessInfoArrayList();
                if (businessInfoArrayList == null) {
                    out.println("<P><B>Nothing found</B>");
                } else {

                    out.println("<P>Business <B>"+searchedBusiness+"</B> found");
                    for (Iterator iterator = 
                       businessInfoArrayList.iterator(); iterator.hasNext();) {
                        BusinessInfo businessInfo = (BusinessInfo) iterator.next();
                        out.println("<P>Business key : <B>" + 
                            businessInfo.getBusinessKey()+"</B>");
                        out.println("<P><TEXTAREA ROWS=10 COLS=70>");
                        out.println(businessInfo.toXML());
                        out.println("</TEXTAREA");

                    }

                }
            }
            out.println("</HTML>");
        } catch (InvalidParameterException e) {
            System.out.println("_InvalidParameterException "+e.getMessage());
        } catch (InstanceNotFoundException e) {
            System.out.println("_InstanceNotFoundException "+e.getMessage());
        } catch (UDDIException e) {
           System.out.println("_UDDIException "+e.getMessage());
        }

    }
}

        

Example 6. Example Servlet's web.xml

<servlet>
    <servlet-name>ExampleServlet</servlet-name>    
    <servlet-class>com.systinet.example.servlet.ExampleServlet</servlet-class>
</servlet>

<servlet-mapping>
    <servlet-name>ExampleServlet</servlet-name>
    <url-pattern>/myexamples/*</url-pattern>
</servlet-mapping>