Oracle JDeveloper 11g JAX-WS Web Services

33
SAGE Computing Services Customised Oracle Training Workshops and Consulting Chris Muir Oracle Consultant and Trainer http://one-size-doesnt-fit-all.blogspot.com Oracle ACE Director - Fusion Middleware JDeveloper 11g JAX-WS web services: ....as easy as 1-2-3: XSD, WSDL, Generate!

Transcript of Oracle JDeveloper 11g JAX-WS Web Services

Page 1: Oracle JDeveloper 11g JAX-WS Web Services

SAGE Computing Services

Customised Oracle Training Workshops and Consulting

Chris Muir

Oracle Consultant and Trainer

http://one-size-doesnt-fit-all.blogspot.com

Oracle ACE Director - Fusion Middleware

JDeveloper 11gJAX-WS web services:

....as easy as 1-2-3: XSD, WSDL, Generate!

Page 2: Oracle JDeveloper 11g JAX-WS Web Services

Agenda

• Part I: Web Services

• Part II: JAX-WS & JAXB

• Part III: Demo time!

Page 3: Oracle JDeveloper 11g JAX-WS Web Services

Part I:Web Services

Photo thanks to Lexnger@ Flickr.com under CC 3/15

Page 4: Oracle JDeveloper 11g JAX-WS Web Services

Why web services?

• System to system data integration

• Consumer (client) & Publisher

• Share data

• System interoperability

• Standardized

• Low cost internet delivery

• Loosely coupled

Key Benefits

Photo thanks to vernhart@ Flickr.com under CC 4/15

Page 5: Oracle JDeveloper 11g JAX-WS Web Services

Photo thanks to B.G. - Oodwin & Andrea Fregnani @ Flickr.com under CC

SOAP vs REST Web Services

Page 6: Oracle JDeveloper 11g JAX-WS Web Services

SOAP RPC vs Document Style

Photo thanks to redjar and ARS @ Flickr.com under CC

Page 7: Oracle JDeveloper 11g JAX-WS Web Services

SOAP Web Services Defined

Host: http://www.sagecomputing.com.au

Web

Web Service /bookings

/departments

/timesheets

Supports many operations

Server

Web Service

Web Service

Page 8: Oracle JDeveloper 11g JAX-WS Web Services

SOAP Web Services Defined

Service: http://www.sagecomputing.com.au/departments

WebServiceDepts

getName

getDetails

updateName

Operation

Operation

Operation

Internet(Client)

?

Page 9: Oracle JDeveloper 11g JAX-WS Web Services

SOAP Web Services Defined

WSDL: http://www.sagecomputing.com.au/departments?wsdl

WebServiceDepts

getName

getDetails

updateName

Operation

Operation

Operation

Internet(Client)

HTTP Request

WSDL Please!

Page 10: Oracle JDeveloper 11g JAX-WS Web Services

SOAP Web Services Defined

WSDL: http://www.sagecomputing.com.au/departments?wsdl

WebServiceDepts

getName

getDetails

updateName

Operation

Operation

Operation

Internet(Client)

HTTP Response

Ah huh! Operations

API Style XML Schemas

Page 11: Oracle JDeveloper 11g JAX-WS Web Services

SOAP Web Services Defined

Service: http://www.sagecomputing.com.au/departments

WebServiceDepts

getName

getDetails

updateName

Operation

Operation

Operation

Internet(Client)

HTTP Request

XML Payload

Page 12: Oracle JDeveloper 11g JAX-WS Web Services

SOAP Web Services Defined

Service: http://www.sagecomputing.com.au/departments

WebServiceDepts

getName

getDetails

updateName

Operation

Operation

Operation

Internet(Client)

HTTP Response

XML Payload

Thank you!

Thinking thinkingthinking

Page 13: Oracle JDeveloper 11g JAX-WS Web Services

SOAP Core Concepts

• HTTP

–URL

• Web Services (aka. endpoints)

–Operations

»Parameters

• Based on XML Schemas

• XML Payloads

• WSDL

Page 14: Oracle JDeveloper 11g JAX-WS Web Services

Part II:JAX-WS & JAXB

Photo thanks to Lexnger@ Flickr.com under CC 3/15

Page 15: Oracle JDeveloper 11g JAX-WS Web Services

WS Framework Challenges

• Obscure underlying implementation detail from programmer:

–HTTP request/responses

– SOAP envelope

• XML to native language datatype mapping

• WSDL/SOAP mapping to code

Page 16: Oracle JDeveloper 11g JAX-WS Web Services

• Java API for Web Services

• JAX-WS 2.x replaces JAX-RPC in JEE5

• Standards based

• Apart of the Glassfish "Metro" web service stack of technologies

JAX-WS

• Simplified POJOs

• Uses annotation

• Easy to understand

• No code for HTTP

• No code for transport layer

• Focus on the data rather than mechanics

Page 17: Oracle JDeveloper 11g JAX-WS Web Services

• Can create both the publisher (aka. provider or web service) and client (aka. consumer)

– Publisher = JEE5.0 + Client = JSE6.0

– Primarily SOAP based web services

– Also supports RESTful based web services

– Support for SOAP 1.1/1.2

– Support for binary attachments (MTOM)

• RI includes command line tools for generating artefacts- WSImport - top down - create service from WSDL- WSGen - bottom up - create service from Java code

• JDeveloper IDE provides an easier wizard driven interface

JAX-WS Implementation

Page 18: Oracle JDeveloper 11g JAX-WS Web Services

• Incoming request - XML "unmarshalled" into Java objects

• Outgoing response - Java objects are "marshalled" into XML

• JAX-WS supports multiple XML 2 Java binding technologies

– map XML to Java equivalent

– provide Java the ability to consume/create XML data

– JAX-WS support multiple binding types:

• XML Source (DOM)

• SAAJ (SOAPMessage)

• Activation data sources (Streams - raw text - similar i/o)

• Java Architecture for XML Binding (JAXB)

• JAXB object structure is familiar to Java programmers

• No more XML

JAX-WS XML 2 Java binding

Page 19: Oracle JDeveloper 11g JAX-WS Web Services
Page 20: Oracle JDeveloper 11g JAX-WS Web Services

Part III:JDeveloper

Demonstration

Photo thanks to philippe leroyer @ Flickr.com under CC 3/15

Page 21: Oracle JDeveloper 11g JAX-WS Web Services

....as easy as 1-2-3: XSD, WSDL, Generate!

Page 22: Oracle JDeveloper 11g JAX-WS Web Services

Create your XML Schema

Page 23: Oracle JDeveloper 11g JAX-WS Web Services

Create the web service WSDL

Page 24: Oracle JDeveloper 11g JAX-WS Web Services

Generate the code

Page 25: Oracle JDeveloper 11g JAX-WS Web Services

Ah, test it

Page 26: Oracle JDeveloper 11g JAX-WS Web Services

Bottoms up!

Page 27: Oracle JDeveloper 11g JAX-WS Web Services

Photo thanks to A National Acrobat @ Flickr.com under CC

But I'm a PL/SQL programmer!

Page 28: Oracle JDeveloper 11g JAX-WS Web Services
Page 29: Oracle JDeveloper 11g JAX-WS Web Services

01 CREATE TABLE dept (deptno NUMBER(2,0), dname VARCHAR2(14));

02

03 CREATE TYPE dept_type AS OBJECT

04 (deptno NUMBER

05 ,dname VARCHAR2(14)

06

07 CREATE TYPE dept_list_table IS TABLE OF dept_type;

08

09 CREATE OR REPLACE PACKAGE ws_package AS

10 FUNCTION test_dept_table RETURN dept_list_table;

11 END ws_package;

12

13 CREATE OR REPLACE PACKAGE BODY ws_package AS

14 FUNCTION test_dept_table RETURN dept_list_table IS

15 all_depts dept_list_table := dept_list_table();

16 dRecType dept_type;

17 i NUMBER := 0;

18 BEGIN

19 FOR r_list IN (SELECT * FROM dept) LOOP

20 i := i + 1;

21 dRecType := dept_type(null, null, null, null);

22 dRecType.deptno := r_list.deptno;

23 dRecType.dname := r_list.dname;

24 all_depts.extend;

25 all_depts(i) := dRecType;

26 END LOOP;

27

28 RETURN all_depts;

29 END test_dept_table;

30 END ws_package;

Page 30: Oracle JDeveloper 11g JAX-WS Web Services

Photo thanks to Romy Schneider @ Flickr.com under CC

Page 31: Oracle JDeveloper 11g JAX-WS Web Services

Photo thanks to badjonni & massdistraction @ Flickr.com under CC

Page 32: Oracle JDeveloper 11g JAX-WS Web Services

SAGE Computing Services

Customised Oracle Training Workshops and Consulting

Questions and Answers?

Presentations are available from our website:

www.sagecomputing.com.au

[email protected]

[email protected]

http://one-size-doesnt-fit-all.blogspot.com

Page 33: Oracle JDeveloper 11g JAX-WS Web Services

JDeveloper Web Services References

Pas Apicella bloghttp://theblasfrompas.blogspot.com

(Many thanks to Pas for the PL/SQL example:http://theblasfrompas.blogspot.com/2009/08/jdeveloper-11g-

plsql-web-service.html)

Edwin Biemond's bloghttp://biemond.blogspot.com

Gerard Davison bloghttp://kingsfleet.blogspot.com