Presentation is loading. Please wait.

Presentation is loading. Please wait.

Kuassi Mensah Java Products Group Stephen Jones Oracle University.

Similar presentations


Presentation on theme: "Kuassi Mensah Java Products Group Stephen Jones Oracle University."— Presentation transcript:

1

2 Kuassi Mensah Java Products Group Stephen Jones Oracle University

3 Build Your First Database Web Services

4 Agenda  Web Services Concepts  Database as Service Provider  Database as Service Consumer  Conclusions

5 Traditional Web versus Web Services Web Site HTTP (HTML) SOAP RMI Firewall Web Browser Applications JSP, Servlets EJBs Web Services Applications Web Services provide a way for applications to publish and invoke functionality across the internet in a language independent manner

6 Web Services -- The Basic Ingredients  SOAP - Simple Object Access Protocol – Transport-independent XML messaging protocol  WSDL - Web Services Definition Language – Declares in an XML document everything you need to know to use a web service  UDDI - Universal Description, Discovery, and Integration – A directory to publish and find web services

7 SOAP, WSDL, UDDI Together WSDL Document Web Service Supplier 4. Invoke SOAP UDDI Repository 1. Publish 2. Find 3. Bind Web Service Consumer Service Servlet

8 J2EE-based Web Services Endpoint implicitly specifies the type of service provided by the server SSBMDBorJavaClass SOAP response per WSDL Oracle Application Server Containers for J2EE HTTP XML Parser SOAPLibraries OC4JWebServicesServlet Decoding Encoding

9 Database Web Service Endpoint implicitly specifies the type of service provided by the server XML Parser SOAPLibraries OC4JWebServicesServlet Decoding Encoding JPubGeneratedJavaClasses SOAP response per WSDL HTTP JDBC

10 Using a Web Service  Static Binding – Use the WSDL to get the proxy jar http://host:port/StatelessTest?proxy.jar – Jar contains proxy class that communicates via SOAP to the server – Write client code to use the proxy  Dynamic Binding – Set up Service and Call objects at Runtime – Invoke Operations through a Generic list of input argument – Get a return value as well as a list of output values

11 Example - Stateless Java Class Stateless Java Web Service oracle.j2ee.ws.StatelessJavaRpcWebService class-name myJavaClass.class interface-name myJavaInterface.class Stateless Java Web Service /StatelessTest Class you wrote Methods to expose How it is invoked Web Services servlet

12 Agenda  Web Services Concepts  Database as Service Provider – Setting Up OC4J – The Web Service Assembler – Building your First Query and DML Web Services – Build your First PL/SQL and DB-Java Web Services  Database as Service Consumer  Conclusions

13 Database as Web Services Provider SOAP J2EE (Business Logic) Oracle9iAS Web Services Framework Web Service Client Data Data Logic SQL/Query SQL/DML JavaPL/SQL OracleApplication Server 10 Server 10g JDBC Oracle Database 10 Database 10g

14 Setting Up OC4J  Modify data-sources.xml to point to the running instance : : " inactivity-timeout="30" />

15 The Web Service Assembler  Utility for creating Web Services as J2EE EAR – Uses JPublisher for generating Java code corresponding to the Web Service – Takes input from XML-based config files  Service-config.xml  Client-config.xml  Invoked as follow % java -jar wsa.jar -config config.xml

16 The Web Service Assembler -- Service Config file how it is invoked scott/tiger jdbc:oracle:thin:@localhost:5521:sqlj jdbc/OracleDS directives for JPublisher processing flags (optional) … the database resource to be published as a Web Service … …

17 Building your first Query Web Services  Motivations  Step#1 – Assembling your Query Web Service./build/query.ear /query getEmp select ename from emp where ename=:{myname VARCHAR}

18 Building your first Query Web Services (II)  Step#2 - Generating an ear file containing the Java wrapper % java -jar /webservices/lib/wsa.jar -config service-config.xml The following files will be generated build/query.ear - the webservices application build/src - subdirectory holding client proxy source code build/classes - subdirectory holder client proxy.class files.

19 Building your first Query Web Services (III)  Step#3 – Deploy the Generated EAR to OC4J % java -jar /j2ee/home/admin.jar ormi:// : admin -deploy -file build/query.ear - deploymentName query  Step#4 – Binding the Deployed Application % java -jar /j2ee/home/admin.jar ormi:// : admin -bindWebApp query query-web http-web-site query At this stage, the Web Service has been deployed!

20 Building your first Query Web Services (IV)  Step#5 – Generating the Client Application mapping.xml build/src/client oracle.demo.db.query.stub build/classes/client % java -jar $ORACLE_HOME/webservices/wsa.jar -config client-config.xml  Step#6 – Binding the Deployed Application % java -jar /j2ee/home/admin.jar ormi:// : admin - bindWebApp query query-web http-web-site query At this stage, the Web Service has been deployed!

21 Building your first Query Web Services (V)  Step#6 – Compiling and Running the Client Application Compile and run the sample client program in src/client/oracle/demo/db/query/QueryClient.java % ant compile-client % ant run-client [java] *** Query Emp Rows by ID returns 1 rows [java] *** Query Emp Rows by ID returns  Step#7 – Accessing the Service via Browser http://localhost:8888/query/query

22 Building your First PL/SQL Web Services  Step#1 – Assemble PL/SQL Web Services Company method1 method2  Step#2-7 Same as Query Web Services

23 Building your First DB-Java Web Services  Step#1 – Assemble DB-Java Web Services foo.bar.Baz method1 method2  Step#2-7 Same as Query Web Services

24 Agenda  Introduction – Web Services Concepts  Database as Service Provider  Database as Service Consumer  Conclusions

25 Database as Web Services Consumer Oracle9iAS Web Services Framework Data Data Logic Batch Jobs XML SOAP Message Web Service Provider Service SQL Java PL/SQL WSDL

26 Building your First “Database as Web Service Consumer”  Motivations  Step#1 – Setting up the Database for Call-out – For Oracle Database 10g Production: sqljutl.jar, utl_dbws_jserver.jar, as well as the SYS.UTL_DBWS packages are loaded at install time - For 10g Beta databases, run initdbws.sql SQL>conn / as sysdba SQL>@initdbws SQL>@sqljutl.sql – For 9i databases run initdbws9.sql SQL>conn / as sysdba SQL>@initdbws9 SQL>@sqljutl.sql

27 Reminder -- Using a Web Service  Dynamic Binding – Set up Service and Call objects at Runtime – Invoke Operations through a Generic list of input argument – Get a return value as well as a list of output values Load the Java client in OracleJVM and you are done!  Static Binding – see Step#2 – Use the WSDL to get the proxy jar http://host:port/StatelessTest?proxy.jar – Jar contains proxy class that communicates via SOAP to the server – Write client code to use the proxy See Step#2-4

28 Building your First “Database as Web Service Consumer” (II)  Step#2 – Generating the required files New JPublisher options automates – The generation of the client proxy, Compiling it, JARing it, and Loading it in the database % jpub -proxywsdl= URL_of_Web_Service_WSDL -dir=genproxy -package=javacallout -user=username/password -endpoint=external_Web_Services_URL [-url=JDBC_database_URL ] JPublisher will generate the Java proxy classes, the PL/SQL wrappers and load the appropriate files

29 Building your First “Database as Web Service Consumer” (III)  Step#3 – Granting Privileges Run plsql_grant.sql as SYS to grant necessary privileges for SCOTT to execute the loaded client proxy SQL> conn / as sysdba SQL> @genproxy/plsql_grant.sql

30 Building your First “Database as Web Service Consumer” (IV)  Step#4 – Calling-out the Web Service Declare and Run the sql/run-plsql-proxy.sql script or run the PL/SQL block below SQL> conn / as sysdba SQL>SQL> set serveroutput on SQL> declare x varchar2(100); begin x:=JPUB_PLSQL_WRAPPER.sayHello('Hello from database'); dbms_output.put_line(x); end; /

31 Agenda  Introduction – Web Services Concepts  Database as Service Provider  Database as Service Consumer  Conclusions

32 Summary  The Combination of Database and Web Services allows simple but powerful applications  JPublisher simplifies and automates the process  JDeveloper will make it even simpler  More Details on the Database Web Service center http://otn.oracle.com/tech/webservices/database.html  All codes samples posted on OTN http://otn.oracle.com/sample_code/tech/java/jsp/dbwebservices.h tml

33 A Q & Q U E S T I O N S A N S W E R S

34


Download ppt "Kuassi Mensah Java Products Group Stephen Jones Oracle University."

Similar presentations


Ads by Google