Database Call-out Overview of Database Web Services

10-2 Programming Advanced Features of JAX-RPC Web Services for Oracle WebLogic Server Figure 10–1 Web Service Calling in to the Database The following steps describe the process shown in the previous figure:

1. A request for a type of database service arrives at the application server. The

service endpoint implicitly specifies the type of service requested.

2. The JAX-RPC processing servlet references the SOAP libraries and XML parser to

decode the request.

3. The servlet passes the request to the classes that correspond to the exposed

database operations. The generated classes can represent PLSQL packages, queries, DML, AQ Streams, or Java classes in the database.

4. The database passes the response to the JAX-RPC processing servlet, which

references the SOAP libraries and XML parser to encode it.

5. A SOAP response formed in accordance with the WSDL is returned to the client.

10.1.2 Database Call-out

You can extend a relational databases storage, indexing, and searching capabilities to include Web services. By calling a Web service, the database can track, aggregate, refresh, and query dynamic data produced on-demand, such as stock prices, currency exchange rates, or weather information. An example of using the database as a service consumer would be to call an external Web service from a predefined database job to obtain inventory information from multiple suppliers, then update your local inventory database. Another example is that of a Web Crawler: a database job can be scheduled to collate product and price information from a number of sources. The following figure illustrates database call-out. Figure 10–2 Calling Web Services from Within the Database The following steps describe the process shown in the previous figure: Using Database Web Services 10-3 ■ SQL and PLSQL call specs—Invoke a Web service through a user-defined function call either directly within a SQL statement or view, or through a variable. ■ Dynamic Web service invocation using the UTL_DBWS PLSQL package. A Call object can be dynamically created based on a WSDL and subsequently, Web services operations can be invoked. Oracle Database PLSQL Packages and Types Reference provides more information on using the UTL_DBWS PLSQL package. ■ Pure Java static proxy class—Generate a client proxy class which uses JAX-RPC. This method simplifies the Web service invocation as the location of the service is already known without needing to look up the service in the UDDI registry. The client proxy class does all of the work to construct the SOAP request, including marshalling and unmarshalling parameters. ■ Pure Java using DII dynamic invocation interface over JAX-RPC—Dynamic invocation provides the ability to construct the SOAP request and access the service without the client proxy. Which method to use depends on whether you want to execute from SQL or PLSQL, from Java classes, or whether the service is known ahead of time static invocation or only at runtime DII.

10.2 Type Mapping Between SQL and XML

The following sections describe the type mappings between SQL and XML for call-ins and call-outs when the Web service is known ahead of time static invocation. When the Web service is known at runtime you can use only the Dynamic Invocation Interface DII or the UTL_DBWS PLSQL package. For more information on using the JAX-RPC DII, see the API at the following Web address: http:java.sun.comj2ee1.4docsapi .

10.2.1 SQL to XML Type Mappings for Web Service Call-Ins

In a database Web service call-in, a SQL operation, such as a PLSQL stored procedure or a SQL statement, is mapped into one or more Web service operations. The parameters to the SQL operation are mapped from SQL types into XML types. The following table illustrates the SQL-to-XML mappings for Web service call-ins. The first column lists the SQL types. The second column of the table, XML Type Literal, shows SQL-to-XML type mappings for the default literal value of the use attribute. The third column, XML Type Encoded, shows the mappings for the encoded value of the use attribute. The literal and encoded values refer to the rules for encoding the body of a SOAP message. Note: The reason there may be more than one operation is because OracleAS Web services may be providing additional data representation choices for the SQL values in XML, such as different representations of SQL result sets. Table 10–1 SQL-to-XML Type Mappings for Web Services Call-ins SQL Type XML Type Literal XML Type Encoded INT int int