Accessing Backend APIs Server-Side Development

REGISTRY_HOME\lib\wasp.jar; J2EE_HOME\common\lib\servet-api.jar ExampleServlet.java 2. Create deployment packagedirectory that will include compiled class and web.xml as shown in Example 5, Example Servlets web.xml . 3. Deploy the package. You can test it as shown at Figure 7 . Figure 7. Example Servlet Output Page 530

3.1. Accessing Backend APIs

Example 4. 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 doGetHttpServletRequest request, HttpServletResponse response throws IOException, ServletException { try { String searchedBusiness = request.getParametersbusiness; if searchedBusiness == null searchedBusiness = ; response.setContentTypetexthtml; PrintWriter out = response.getWriter; out.printlnHTML; out.printlnHEAD; out.printlnH1Example servlet integration with RegistryH1; out.printlnPEnter the business name you wish to search; out.printlnFORM METHOD=GET ACTION=waspmyexamples; out.printlnINPUT NAME=sbusiness SIZE=20 VALUE= + searchedBusiness + ; out.printlnINPUT TYPE=SUBMIT VALUE=Search; out.printlnFORM; get UDDI API V3 Inquiry implementation UDDI_Inquiry_PortType inquiry = UDDI_Inquiry_PortType Context.getInstanceUDDI_Inquiry_PortType.class; prepare find_business call Find_business find_business = new Find_business; if searchedBusiness.length 0 { find_business.addNamenew NamesearchedBusiness; out.printlnPSearching business : + searchedBusiness; call find_business BusinessList businessList = inquiry.find_businessfind_business; process the result BusinessInfoArrayList businessInfoArrayList = businessList.getBusinessInfoArrayList; if businessInfoArrayList == null { out.printlnPBNothing foundB; Page 531

3.1. Accessing Backend APIs

} else { out.printlnPBusiness B+searchedBusiness+B found; for Iterator iterator = businessInfoArrayList.iterator; iterator.hasNext; { BusinessInfo businessInfo = BusinessInfo iterator.next; out.printlnPBusiness key : B + businessInfo.getBusinessKey+B; out.printlnPTEXTAREA ROWS=10 COLS=70; out.printlnbusinessInfo.toXML; out.printlnTEXTAREA; } } } out.printlnHTML; } catch InvalidParameterException e { } catch InstanceNotFoundException e { } catch UDDIException e { } } } Example 5. Example Servlets web.xml servlet servlet-nameExampleServletservlet-name servlet-classcom.systinet.example.servlet.ExampleServletservlet-class servlet servlet-mapping servlet-nameExampleServletservlet-name url-patternmyexamplesurl-pattern servlet-mapping

3.2. Custom Registry Modules

In this section, we will show you how to extend Oracle Service Registry functionality with your custom modules. Custom modules can be added to Oracle Service Registry as shown in Figure 8 . Page 532

3.2. Custom Registry Modules

Figure 8. Custom Registry Module - Architecture View To create and deploy a registry module, follow these steps: 1. Write a class that implements org.systinet.uddi.module.Module. 2. Copy your module implementation class to the directory REGISTRY_HOMEappuddiservicesWASP-INFclasses. 3. Create a configuration file for the module in REGISTRY_HOMEappuddiconf. 4. Shutdown Oracle Service Registry, delete the REGISTRY_HOMEwork directory, and restart the registry. The main class of the custom module must implement org.systinet.uddi.module.Module interface that has these methods: • load is invoked as the first method of the module. You can put reading of the configuration file in here. • init is invoked after the load method. Put the core implementation of your module in here. Write non-blocking code or start a new thread. • destroy is invoked just before the Oracle Service Registry shutdown.

3.2.1. Accessing Registry APIs

To access the Oracle Service Registry API you must obtain the API stub using the getApiInstance method of the API implementation class. For example to obtain the stub of the Statistics API use: StatisticsApi statapi = StatisticsApiImpl.getApiInstance; Mapping between API interface classes and implementation classes is stored in the REGISTRY_HOMEappuddiservicesWASP-INFpackage.xml file. See Table 53, “Mapping API Interface and Implemenation Classes” . Page 533

3.2.1. Accessing Registry APIs