Raastech, Inc.
2201 Cooperative Way, Suite 600
Herndon, VA 20171
+1-703-884-2223
info@raastech.com
Developing Web Services from Scratch
For DBAs and Database Developers
BGOUG Spring 2017 Conference
Hotel RIU Pravets Resort
Saturday, June 3, 2017
16:00 - 17:00
Hall B
© Raastech, Inc. 2017 | All rights reserved. Slide 2 of 61@Raastech
Agenda
1. Introduction
2. Introducing Web Services
3. Accessing a Web Service
4. Anatomy of a WSDL
5. Getting Started: Concepts
6. Live Development Demo
 Java Web Service: Top-Down Development
 Java Web Service: Bottom-Up Development
 BPEL Web Service
7. Recap & Summary
© Raastech, Inc. 2017 | All rights reserved. Slide 3 of 61@Raastech
© Raastech, Inc. 2017 | All rights reserved. Slide 4 of 61@Raastech
About Me
 Ahmed Aboulnaga @Ahmed_Aboulnaga
 18+ years Oracle experience
 Author of “Oracle SOA Suite 11g Administrator’s Handbook”
 Author of “Oracle SOA Suite 12c Administrator’s Guide”
 OCE (SOA Foundation Practitioner)
 Oracle ACE
© Raastech, Inc. 2017 | All rights reserved. Slide 5 of 61@Raastech
About Raastech
 Small systems integrator founded in 2009
 Headquartered in the Washington DC area
 Specializes in Oracle Fusion Middleware
 Oracle Gold Partner
 Oracle SOA Specialized
© Raastech, Inc. 2017 | All rights reserved. Slide 6 of 61@Raastech
Why This Presentation
 Learn to develop a web service from scratch
 Lot of PL/SQL developers are intimidated by SOA development
 Presentation is specific to SOAP, but concepts are similar for REST
© Raastech, Inc. 2017 | All rights reserved. Slide 7 of 61@Raastech
© Raastech, Inc. 2017 | All rights reserved. Slide 8 of 61@Raastech
 How application access was previously developed
PL/SQL
ProcedurePL/SQL
Procedure
SQL
Developer
Java
Application
.NET
Application
ODBC driver
JDBC driver
SQL*NET
(internal)
Custom Drivers
© Raastech, Inc. 2017 | All rights reserved. Slide 9 of 61@Raastech
 ProC anyone?
 Must be aware of the
technology of the target system
implementation and import the
necessary libraries and drivers
compatible with that technology
PL/SQL
ApplicationJava
Application
AS/400
Mainframe
.NET
Application
.NET drivers
IBM JARs
JDBC driver
Specific Target Implementation
© Raastech, Inc. 2017 | All rights reserved. Slide 10 of 61@Raastech
 Standardization on SOAP over HTTP
Web
ServiceAny
Application
Java
Application
.NET
Application
SOAP over HTTP
SOAP over HTTP
SOAP over HTTP
SOAP over HTTP
© Raastech, Inc. 2017 | All rights reserved. Slide 11 of 61@Raastech
 No need to worry about
implementation technology
of target applications
AWS
Java
Application
SalesForce
Paypal
SOAP over HTTP
SOAP over HTTP
SOAP over HTTP
Agnostic Target Implementation
© Raastech, Inc. 2017 | All rights reserved. Slide 12 of 61@Raastech
CREATE PROCEDURE getWeather (
zipcode IN VARCHAR2,
temperature OUT NUMBER)
IS
BEGIN
temperature := '35';
END;
CREATE PROCEDURE setWeather (
zipcode IN VARCHAR2,
temperature IN NUMBER)
IS
BEGIN
INSERT INTO temperature
VALUES (zipcode, temperature);
END;
Request-Response
Synchronous
1-way
Asynchronous
PL/SQL Samples
© Raastech, Inc. 2017 | All rights reserved. Slide 13 of 61@Raastech
PL/SQL
Procedure
PL/SQL
Procedure
PL/SQL
Procedure
PL/SQL
Procedure
Synchronous vs. Asynchronous
© Raastech, Inc. 2017 | All rights reserved. Slide 14 of 61@Raastech
© Raastech, Inc. 2017 | All rights reserved. Slide 15 of 61@Raastech
 Now that business functionality is exposed as web services, these
services need to be consumed somehow.
 Since web services are standards based, they can be invoked via the
majority of programming languages or through other services.
Web Service Clients
© Raastech, Inc. 2017 | All rights reserved. Slide 16 of 61@Raastech
soapUI
© Raastech, Inc. 2017 | All rights reserved. Slide 17 of 61@Raastech
 The web service interface is accessible via an HTTP URL:
http://admin.raastech.com:7001/GetWeather/WeatherPort?WSDL
 The web service implementation may or may not reside on the same
service:
<soap:address location="http://srv.raastech.com:8888/GetWeather/WeatherPort"/>
 Often impossible to tell what underlying language was used to create
the web service.
Accessing a WSDL
© Raastech, Inc. 2017 | All rights reserved. Slide 18 of 61@Raastech
© Raastech, Inc. 2017 | All rights reserved. Slide 19 of 61@Raastech
<definitions name="Weather">
<types>
<schema>
<element name="zip" type="string"/>
<element name="temp" type="string"/>
</schema>
</types>
<message name="zipReq"><part name="parameters" element="zip"/></message>
<message name="tempResp"><part name="parameters" element="temp"/></message>
<portType name="WeatherPort">
<operation name="getWeather">
<input message="zipReq"/>
<output message="tempResp"/>
</operation>
</portType>
<binding name="WeatherBinding" type="WeatherPort">
<operation name="getWeather">
<input name="zipReq"/>
<output name="tempResp"/>
</operation>
</binding>
<service name="WeatherService">
<port name="WeatherPort" binding="WeatherBinding">
<soap:address location="http://localhost/wc/weather"/>
</port>
</service>
</definitions>
The WSDL is the
interface to the
web service.
Implementation
details of the web
service is unknown.
Dissecting a WSDL: Interface
© Raastech, Inc. 2017 | All rights reserved. Slide 20 of 61@Raastech
<definitions name="Weather">
<types>
<schema>
<element name="zip" type="string"/>
<element name="temp" type="string"/>
</schema>
</types>
<message name="zipReq"><part name="parameters" element="zip"/></message>
<message name="tempResp"><part name="parameters" element="temp"/></message>
<portType name="WeatherPort">
<operation name="getWeather">
<input message="zipReq"/>
<output message="tempResp"/>
</operation>
</portType>
<binding name="WeatherBinding" type="WeatherPort">
<operation name="getWeather">
<input name="zipReq"/>
<output name="tempResp"/>
</operation>
</binding>
<service name="WeatherService">
<port name="WeatherPort" binding="WeatherBinding">
<soap:address location="http://localhost/wc/weather"/>
</port>
</service>
</definitions>
Location is referred
to as the “endpoint”.
Identifies where the
actual code resides.
Dissecting a WSDL: Endpoints
© Raastech, Inc. 2017 | All rights reserved. Slide 21 of 61@Raastech
<definitions name="Weather">
<types>
<schema>
<element name="zip" type="string"/>
<element name="temp" type="string"/>
</schema>
</types>
<message name="zipReq"><part name="parameters" element="zip"/></message>
<message name="tempResp"><part name="parameters" element="temp"/></message>
<portType name="WeatherPort">
<operation name="getWeather">
<input message="zipReq"/>
<output message="tempResp"/>
</operation>
</portType>
<binding name="WeatherBinding" type="WeatherPort">
<operation name="getWeather">
<input name="zipReq"/>
<output name="tempResp"/>
</operation>
</binding>
<service name="WeatherService">
<port name="WeatherPort" binding="WeatherBinding">
<soap:address location="http://localhost/wc/weather"/>
</port>
</service>
</definitions>
This web service
has a single
operation, with an
input and an output
(i.e., synchronous).
Dissecting a WSDL: Operations
© Raastech, Inc. 2017 | All rights reserved. Slide 22 of 61@Raastech
<definitions name="Weather">
<types>
<schema>
<element name="zip" type="string"/>
<element name="temp" type="string"/>
</schema>
</types>
<message name="zipReq"><part name="parameters" element="zip"/></message>
<message name="tempResp"><part name="parameters" element="temp"/></message>
<portType name="WeatherPort">
<operation name="getWeather">
<input message="zipReq"/>
<output message="tempResp"/>
</operation>
</portType>
<binding name="WeatherBinding" type="WeatherPort">
<operation name="getWeather">
<input name="zipReq"/>
<output name="tempResp"/>
</operation>
</binding>
<service name="WeatherService">
<port name="WeatherPort" binding="WeatherBinding">
<soap:address location="http://localhost/wc/weather"/>
</port>
</service>
</definitions>
The type of the
message is defined
in the “schema”.
Dissecting a WSDL: Messages
© Raastech, Inc. 2017 | All rights reserved. Slide 23 of 61@Raastech
JavaBPEL
getCustomerSoapUI
getCustomerSoapUI
Today’s Live Development Demo
© Raastech, Inc. 2017 | All rights reserved. Slide 24 of 61@Raastech
© Raastech, Inc. 2017 | All rights reserved. Slide 25 of 61@Raastech
 http://www.w3schools.com/xml/default.asp
 http://www.w3schools.com/schema/default.asp
 http://www.w3schools.com/xpath/default.asp
 http://www.w3schools.com/xsl/default.asp
 http://www.w3schools.com/xquery/default.asp
 http://www.w3schools.com/webservices/default.asp
 http://www.w3schools.com/webservices/ws_wsdl_intro.asp
 http://www.w3schools.com/webservices/ws_soap_intro.asp
 http://blog.raastech.com/2009/01/creating-top-down-java-web-service-for.html
 http://blog.raastech.com/2009/03/creating-bottom-up-java-web-service-for.html
w3schools References
© Raastech, Inc. 2017 | All rights reserved. Slide 26 of 61@Raastech
 XML stands for “EXtensible Markup Language”.
 XML was designed to transport and store data.
 XML is designed to be self-descriptive.
 XML was originally designed to transport and store data.
 XML does not contain any logic.
Introduction to XML
© Raastech, Inc. 2017 | All rights reserved. Slide 27 of 61@Raastech
 XML documents follow a tree structure.
 Every XML document must have 1 root element.
 The root element is the parent of all other elements.
<Customer>
<Name>John Doe</Name>
<OrderNumber>61237</OrderNumber>
<Items>
<Item quantity="2">Book</Item>
</Items>
</Customer>
XML Structure – Root Element
© Raastech, Inc. 2017 | All rights reserved. Slide 28 of 61@Raastech
 Comments
<Customer>
<!-- this is a comment -->
<Name>John Doe</Name>
<OrderNumber>61237</OrderNumber>
<Items>
<Item quantity="2">Book</Item>
</Items>
</Customer>
XML Structure – Comments
© Raastech, Inc. 2017 | All rights reserved. Slide 29 of 61@Raastech
 XML documents must have open and close tags.
 Valid HTML, but invalid XML:
<li> XML is easy
XML Structure – Tags
© Raastech, Inc. 2017 | All rights reserved. Slide 30 of 61@Raastech
 Open and close tags must have matching case
 Valid HTML, but invalid XML:
<Customer>John Doe</customer>
XML Structure – Tags
© Raastech, Inc. 2017 | All rights reserved. Slide 31 of 61@Raastech
 XML elements must be properly nested
 Valid HTML, but invalid XML:
<b><u>Hello World</b><u>
XML Structure – Tags
© Raastech, Inc. 2017 | All rights reserved. Slide 32 of 61@Raastech
 Entity reference.
&lt; < less than
&gt; > greater than
&amp; & ampersand
&apos; ' apostrophe
&quot; " quotation mark
XML Structure – Entity Reference
© Raastech, Inc. 2017 | All rights reserved. Slide 33 of 61@Raastech
 Unlike HTML, whitespace is preserved in XML.
<Customer>
<Name>John Doe
is a person. His age is 20.</Name>
</Customer>
XML Structure – Whitespace
© Raastech, Inc. 2017 | All rights reserved. Slide 34 of 61@Raastech
 Attributes
<Customer OrderNumber="61237">
<Items>
<Item quantity="2">Book</Item>
<Item quantity="1">Binder</Item>
</Items>
</Customer>
XML Structure – Attributes
© Raastech, Inc. 2017 | All rights reserved. Slide 35 of 61@Raastech
 Should you use elements or attributes when designing XML
documents?
<Customer>
<OrderNumber>61237</OrderNumber>
<Items>
<Item quantity="1">Binder</Item>
</Items>
</Customer>
<Customer OrderNumber="61237">
<Items>
<Item quantity="1">Binder</Item>
</Items>
</Customer>
XML Structure – Attributes vs. Elements
© Raastech, Inc. 2017 | All rights reserved. Slide 36 of 61@Raastech
 Namespaces are identifiers.
<Customers>
<e:Customer xmlns:e="http://raastech.com/Employees">
<e:Name>John Doe</e:Name>
</e:Customer>
<p:Customer xmlns:p="http://raastech.com/Partners">
<p:Name>Jane Doe</p:Name>
</p:Customer>
<Customers>
XML Structure – Namespaces
© Raastech, Inc. 2017 | All rights reserved. Slide 37 of 61@Raastech
 Default namespace; no need to prefix all child elements.
<Customer xmlns="http://raastech.com/Employees">
<Name>John Doe</Name>
</Customer>
XML Structure – Default Namespace
© Raastech, Inc. 2017 | All rights reserved. Slide 38 of 61@Raastech
 XML Schema defines elements in an XML document.
 XML Schema defines attributes in an XML document.
 XML Schema defines child elements, and optionally their number
and order.
 XML Schema defines data types for both elements and attributes.
 XML Schema defines default and fixed values for elements and
attributes.
Introduction to XML Schema
© Raastech, Inc. 2017 | All rights reserved. Slide 39 of 61@Raastech
 XML Schemas are well-formed XML documents and are extensible.
 They are typically saved as .xsd files.
 The root element of every XML Schema is the <schema> element.
 The <schema> element may include attributes such as the XML
namespace.
Introduction to XML Schema
© Raastech, Inc. 2017 | All rights reserved. Slide 40 of 61@Raastech
<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified">
<xs:element name="Customer">
<xs:complexType>
<xs:sequence>
<xs:element name="OrderNumber" type="xs:string"/>
<xs:element name="Name" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
Example of an XML Schema
© Raastech, Inc. 2017 | All rights reserved. Slide 41 of 61@Raastech
 A simple element contains only plain text that can be defined in one
of several predefined data types (or custom types).
 The predefined data types in XML Schema include:
 string
 decimal
 integer
 boolean
 date
 time
Simple Element
© Raastech, Inc. 2017 | All rights reserved. Slide 42 of 61@Raastech
 String
<someelement>Hello World</someelement>
 Decimal
<someelement>12.50</someelement>
 Integer
<someelement>12</someelement>
 Boolean
<someelement>true</someelement>
Data Types
© Raastech, Inc. 2017 | All rights reserved. Slide 43 of 61@Raastech
 Date
<someelement>2002-09-24Z</someelement>
<someelement>2008-07-24-06:00</someelement>
 Time
<someelement>08:00:00</someelement>
 DateTime
<someelement>2008-07-24T08:00:00</someelement>
Data Types
© Raastech, Inc. 2017 | All rights reserved. Slide 44 of 61@Raastech
 Restrictions are also referred to as facets.
 Examples include:
 minInclusive
 maxInclusive
 Enumeration
 fractionDigits
 Length
 maxInclusive
 maxExclusive
 maxLength
 minLength
 totalDigits
Restrictions
© Raastech, Inc. 2017 | All rights reserved. Slide 45 of 61@Raastech
 Complex elements are XML elements that contains other elements
or attributes.
<xs:element name="Customer">
<xs:complexType>
<xs:sequence>
<xs:element name="Name" type="xs:string"/>
<xs:element name="Item" type="xs:ItemType" minOccurs="1" maxOccurs="5"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:complexType name="ItemType">
<xs:sequence>
<xs:element name="Item" type="xs:string"/>
<xs:element name="Price" type="xs:decimal"/>
</xs:sequence>
</xs:complexType>
Complex Element
© Raastech, Inc. 2017 | All rights reserved. Slide 46 of 61@Raastech
 SOAP stands for Simple Object Access Protocol.
 It is a communication protocol and allows XML documents to be
exchange over HTTP.
 As a result, it is platform and technology independent, and ideal for
Internet-based communication.
 A SOAP message is an XML document that contains the following:
 Envelope
 Header
 Body
 Fault
Introduction to SOAP
© Raastech, Inc. 2017 | All rights reserved. Slide 47 of 61@Raastech
 Envelope
 Root element of a SOAP message.
 xmlns:soap namespace should always have the value of
http://www.w3.org/2001/12/soap-envelope.
 Header
 Optional.
 Could include information such as authentication information.
 First child element of the Envelope element.
 Body
 Required.
 Contains the content of the SOAP message (i.e., the payload).
SOAP Message
© Raastech, Inc. 2017 | All rights reserved. Slide 48 of 61@Raastech
 Example:
<?xml version="1.0"?>
<soap:Envelope xmlns:soap="http://www.w3.org/2001/12/soap-envelope">
<soap:Header>
</soap:Header>
<soap:Body>
<m:Customer xmlns:m="http://raastech.com/Customer">
<m:Name>John Doe</m:Name>
</m:Customer>
</soap:Body>
</soap:Envelope>
SOAP Message
© Raastech, Inc. 2017 | All rights reserved. Slide 49 of 61@Raastech
 WSDL stands for Web Services Description Language.
 It is an XML document that describes a web service (i.e., it is the
interface specification for the web service).
 It specifies the location of the web service, the operations it
supports, and the message types.
Introduction to WSDL
© Raastech, Inc. 2017 | All rights reserved. Slide 50 of 61@Raastech
© Raastech, Inc. 2017 | All rights reserved. Slide 51 of 61@Raastech
 A top-down web service begins with a WSDL.
 Stubs for the underlying Java classes are created.
 Live Development Demo
Java Web Service Development: Top-Down
WSDL
(interface)
Java
(Class)
WSDL
(interface)
Create interface first Java class stub auto-created
Webservice
development
(top-down)
© Raastech, Inc. 2017 | All rights reserved. Slide 52 of 61@Raastech
© Raastech, Inc. 2017 | All rights reserved. Slide 53 of 61@Raastech
 A bottom-up web service begins with an already existing Java class.
 Class and methods are easily exposed as a web service interface.
 Live Development Demo
Java Web Service Development: Bottom-Up
Java
(class)
WSDL
(interface)
Java
(class)
WSDL auto-generated
from Java class
Create Java class first
Webservice
development
(bottom-up)
© Raastech, Inc. 2017 | All rights reserved. Slide 54 of 61@Raastech
© Raastech, Inc. 2017 | All rights reserved. Slide 55 of 61@Raastech
 Live Development Demo
BPEL Web Service Development
© Raastech, Inc. 2017 | All rights reserved. Slide 56 of 61@Raastech
© Raastech, Inc. 2017 | All rights reserved. Slide 57 of 61@Raastech
{
"Customer":
{
"FirstName":"John",
"LastName":"Doe"
}
}
<?xml version="1.0"?>
<soap:Envelope
xmlns:soap="http://www.w3.org/2001/12/soap-envelope">
<soap:Body>
<m:Customer xmlns:m="http://raastech.com/Customer">
<m:FirstName>John</m:FirstName>
<m:LastName>Doe</m:LastName>
</m:Customer>
</soap:Body>
SOAP/XML Message
 Strong message type validation
 Based on XML standard
 Wide usage and adoption
 Not size-friendly:
 Size of data: 7 bytes
 Size of message: 236 bytes
REST/JSON Message
 Lightweight and efficient (mobile!)
 Growing usage and adoption
 Most moving to REST now
 Size-friendly:
 Size of data: 7 bytes
 Size of message: 50 bytes
SOAP vs. REST
© Raastech, Inc. 2017 | All rights reserved. Slide 58 of 61@Raastech
 http://www.ateam-oracle.com/performance-study-rest-vs-soap-for-mobile-applications/
SOAP vs. REST
© Raastech, Inc. 2017 | All rights reserved. Slide 59 of 61@Raastech
 Why has web services become the accepted standard?
 Are you more familiar with XML terminology?
 What is a popular SOAP client testing tool?
 What are the components of a SOAP message?
 Can you understand a WSDL when you look at it now?
 What is the difference between top-down and bottom-up web service
development?
 What is REST?
Recap
© Raastech, Inc. 2017 | All rights reserved. Slide 60 of 61@Raastech
Contact Information
 Ahmed Aboulnaga
 Technical Director
 @Ahmed_Aboulnaga
 ahmed.aboulnaga@raastech.com
© Raastech, Inc. 2017 | All rights reserved. Slide 61 of 61@Raastech
Q&A

Developing Web Services from Scratch - For DBAs and Database Developers

  • 1.
    Raastech, Inc. 2201 CooperativeWay, Suite 600 Herndon, VA 20171 +1-703-884-2223 info@raastech.com Developing Web Services from Scratch For DBAs and Database Developers BGOUG Spring 2017 Conference Hotel RIU Pravets Resort Saturday, June 3, 2017 16:00 - 17:00 Hall B
  • 2.
    © Raastech, Inc.2017 | All rights reserved. Slide 2 of 61@Raastech Agenda 1. Introduction 2. Introducing Web Services 3. Accessing a Web Service 4. Anatomy of a WSDL 5. Getting Started: Concepts 6. Live Development Demo  Java Web Service: Top-Down Development  Java Web Service: Bottom-Up Development  BPEL Web Service 7. Recap & Summary
  • 3.
    © Raastech, Inc.2017 | All rights reserved. Slide 3 of 61@Raastech
  • 4.
    © Raastech, Inc.2017 | All rights reserved. Slide 4 of 61@Raastech About Me  Ahmed Aboulnaga @Ahmed_Aboulnaga  18+ years Oracle experience  Author of “Oracle SOA Suite 11g Administrator’s Handbook”  Author of “Oracle SOA Suite 12c Administrator’s Guide”  OCE (SOA Foundation Practitioner)  Oracle ACE
  • 5.
    © Raastech, Inc.2017 | All rights reserved. Slide 5 of 61@Raastech About Raastech  Small systems integrator founded in 2009  Headquartered in the Washington DC area  Specializes in Oracle Fusion Middleware  Oracle Gold Partner  Oracle SOA Specialized
  • 6.
    © Raastech, Inc.2017 | All rights reserved. Slide 6 of 61@Raastech Why This Presentation  Learn to develop a web service from scratch  Lot of PL/SQL developers are intimidated by SOA development  Presentation is specific to SOAP, but concepts are similar for REST
  • 7.
    © Raastech, Inc.2017 | All rights reserved. Slide 7 of 61@Raastech
  • 8.
    © Raastech, Inc.2017 | All rights reserved. Slide 8 of 61@Raastech  How application access was previously developed PL/SQL ProcedurePL/SQL Procedure SQL Developer Java Application .NET Application ODBC driver JDBC driver SQL*NET (internal) Custom Drivers
  • 9.
    © Raastech, Inc.2017 | All rights reserved. Slide 9 of 61@Raastech  ProC anyone?  Must be aware of the technology of the target system implementation and import the necessary libraries and drivers compatible with that technology PL/SQL ApplicationJava Application AS/400 Mainframe .NET Application .NET drivers IBM JARs JDBC driver Specific Target Implementation
  • 10.
    © Raastech, Inc.2017 | All rights reserved. Slide 10 of 61@Raastech  Standardization on SOAP over HTTP Web ServiceAny Application Java Application .NET Application SOAP over HTTP SOAP over HTTP SOAP over HTTP SOAP over HTTP
  • 11.
    © Raastech, Inc.2017 | All rights reserved. Slide 11 of 61@Raastech  No need to worry about implementation technology of target applications AWS Java Application SalesForce Paypal SOAP over HTTP SOAP over HTTP SOAP over HTTP Agnostic Target Implementation
  • 12.
    © Raastech, Inc.2017 | All rights reserved. Slide 12 of 61@Raastech CREATE PROCEDURE getWeather ( zipcode IN VARCHAR2, temperature OUT NUMBER) IS BEGIN temperature := '35'; END; CREATE PROCEDURE setWeather ( zipcode IN VARCHAR2, temperature IN NUMBER) IS BEGIN INSERT INTO temperature VALUES (zipcode, temperature); END; Request-Response Synchronous 1-way Asynchronous PL/SQL Samples
  • 13.
    © Raastech, Inc.2017 | All rights reserved. Slide 13 of 61@Raastech PL/SQL Procedure PL/SQL Procedure PL/SQL Procedure PL/SQL Procedure Synchronous vs. Asynchronous
  • 14.
    © Raastech, Inc.2017 | All rights reserved. Slide 14 of 61@Raastech
  • 15.
    © Raastech, Inc.2017 | All rights reserved. Slide 15 of 61@Raastech  Now that business functionality is exposed as web services, these services need to be consumed somehow.  Since web services are standards based, they can be invoked via the majority of programming languages or through other services. Web Service Clients
  • 16.
    © Raastech, Inc.2017 | All rights reserved. Slide 16 of 61@Raastech soapUI
  • 17.
    © Raastech, Inc.2017 | All rights reserved. Slide 17 of 61@Raastech  The web service interface is accessible via an HTTP URL: http://admin.raastech.com:7001/GetWeather/WeatherPort?WSDL  The web service implementation may or may not reside on the same service: <soap:address location="http://srv.raastech.com:8888/GetWeather/WeatherPort"/>  Often impossible to tell what underlying language was used to create the web service. Accessing a WSDL
  • 18.
    © Raastech, Inc.2017 | All rights reserved. Slide 18 of 61@Raastech
  • 19.
    © Raastech, Inc.2017 | All rights reserved. Slide 19 of 61@Raastech <definitions name="Weather"> <types> <schema> <element name="zip" type="string"/> <element name="temp" type="string"/> </schema> </types> <message name="zipReq"><part name="parameters" element="zip"/></message> <message name="tempResp"><part name="parameters" element="temp"/></message> <portType name="WeatherPort"> <operation name="getWeather"> <input message="zipReq"/> <output message="tempResp"/> </operation> </portType> <binding name="WeatherBinding" type="WeatherPort"> <operation name="getWeather"> <input name="zipReq"/> <output name="tempResp"/> </operation> </binding> <service name="WeatherService"> <port name="WeatherPort" binding="WeatherBinding"> <soap:address location="http://localhost/wc/weather"/> </port> </service> </definitions> The WSDL is the interface to the web service. Implementation details of the web service is unknown. Dissecting a WSDL: Interface
  • 20.
    © Raastech, Inc.2017 | All rights reserved. Slide 20 of 61@Raastech <definitions name="Weather"> <types> <schema> <element name="zip" type="string"/> <element name="temp" type="string"/> </schema> </types> <message name="zipReq"><part name="parameters" element="zip"/></message> <message name="tempResp"><part name="parameters" element="temp"/></message> <portType name="WeatherPort"> <operation name="getWeather"> <input message="zipReq"/> <output message="tempResp"/> </operation> </portType> <binding name="WeatherBinding" type="WeatherPort"> <operation name="getWeather"> <input name="zipReq"/> <output name="tempResp"/> </operation> </binding> <service name="WeatherService"> <port name="WeatherPort" binding="WeatherBinding"> <soap:address location="http://localhost/wc/weather"/> </port> </service> </definitions> Location is referred to as the “endpoint”. Identifies where the actual code resides. Dissecting a WSDL: Endpoints
  • 21.
    © Raastech, Inc.2017 | All rights reserved. Slide 21 of 61@Raastech <definitions name="Weather"> <types> <schema> <element name="zip" type="string"/> <element name="temp" type="string"/> </schema> </types> <message name="zipReq"><part name="parameters" element="zip"/></message> <message name="tempResp"><part name="parameters" element="temp"/></message> <portType name="WeatherPort"> <operation name="getWeather"> <input message="zipReq"/> <output message="tempResp"/> </operation> </portType> <binding name="WeatherBinding" type="WeatherPort"> <operation name="getWeather"> <input name="zipReq"/> <output name="tempResp"/> </operation> </binding> <service name="WeatherService"> <port name="WeatherPort" binding="WeatherBinding"> <soap:address location="http://localhost/wc/weather"/> </port> </service> </definitions> This web service has a single operation, with an input and an output (i.e., synchronous). Dissecting a WSDL: Operations
  • 22.
    © Raastech, Inc.2017 | All rights reserved. Slide 22 of 61@Raastech <definitions name="Weather"> <types> <schema> <element name="zip" type="string"/> <element name="temp" type="string"/> </schema> </types> <message name="zipReq"><part name="parameters" element="zip"/></message> <message name="tempResp"><part name="parameters" element="temp"/></message> <portType name="WeatherPort"> <operation name="getWeather"> <input message="zipReq"/> <output message="tempResp"/> </operation> </portType> <binding name="WeatherBinding" type="WeatherPort"> <operation name="getWeather"> <input name="zipReq"/> <output name="tempResp"/> </operation> </binding> <service name="WeatherService"> <port name="WeatherPort" binding="WeatherBinding"> <soap:address location="http://localhost/wc/weather"/> </port> </service> </definitions> The type of the message is defined in the “schema”. Dissecting a WSDL: Messages
  • 23.
    © Raastech, Inc.2017 | All rights reserved. Slide 23 of 61@Raastech JavaBPEL getCustomerSoapUI getCustomerSoapUI Today’s Live Development Demo
  • 24.
    © Raastech, Inc.2017 | All rights reserved. Slide 24 of 61@Raastech
  • 25.
    © Raastech, Inc.2017 | All rights reserved. Slide 25 of 61@Raastech  http://www.w3schools.com/xml/default.asp  http://www.w3schools.com/schema/default.asp  http://www.w3schools.com/xpath/default.asp  http://www.w3schools.com/xsl/default.asp  http://www.w3schools.com/xquery/default.asp  http://www.w3schools.com/webservices/default.asp  http://www.w3schools.com/webservices/ws_wsdl_intro.asp  http://www.w3schools.com/webservices/ws_soap_intro.asp  http://blog.raastech.com/2009/01/creating-top-down-java-web-service-for.html  http://blog.raastech.com/2009/03/creating-bottom-up-java-web-service-for.html w3schools References
  • 26.
    © Raastech, Inc.2017 | All rights reserved. Slide 26 of 61@Raastech  XML stands for “EXtensible Markup Language”.  XML was designed to transport and store data.  XML is designed to be self-descriptive.  XML was originally designed to transport and store data.  XML does not contain any logic. Introduction to XML
  • 27.
    © Raastech, Inc.2017 | All rights reserved. Slide 27 of 61@Raastech  XML documents follow a tree structure.  Every XML document must have 1 root element.  The root element is the parent of all other elements. <Customer> <Name>John Doe</Name> <OrderNumber>61237</OrderNumber> <Items> <Item quantity="2">Book</Item> </Items> </Customer> XML Structure – Root Element
  • 28.
    © Raastech, Inc.2017 | All rights reserved. Slide 28 of 61@Raastech  Comments <Customer> <!-- this is a comment --> <Name>John Doe</Name> <OrderNumber>61237</OrderNumber> <Items> <Item quantity="2">Book</Item> </Items> </Customer> XML Structure – Comments
  • 29.
    © Raastech, Inc.2017 | All rights reserved. Slide 29 of 61@Raastech  XML documents must have open and close tags.  Valid HTML, but invalid XML: <li> XML is easy XML Structure – Tags
  • 30.
    © Raastech, Inc.2017 | All rights reserved. Slide 30 of 61@Raastech  Open and close tags must have matching case  Valid HTML, but invalid XML: <Customer>John Doe</customer> XML Structure – Tags
  • 31.
    © Raastech, Inc.2017 | All rights reserved. Slide 31 of 61@Raastech  XML elements must be properly nested  Valid HTML, but invalid XML: <b><u>Hello World</b><u> XML Structure – Tags
  • 32.
    © Raastech, Inc.2017 | All rights reserved. Slide 32 of 61@Raastech  Entity reference. &lt; < less than &gt; > greater than &amp; & ampersand &apos; ' apostrophe &quot; " quotation mark XML Structure – Entity Reference
  • 33.
    © Raastech, Inc.2017 | All rights reserved. Slide 33 of 61@Raastech  Unlike HTML, whitespace is preserved in XML. <Customer> <Name>John Doe is a person. His age is 20.</Name> </Customer> XML Structure – Whitespace
  • 34.
    © Raastech, Inc.2017 | All rights reserved. Slide 34 of 61@Raastech  Attributes <Customer OrderNumber="61237"> <Items> <Item quantity="2">Book</Item> <Item quantity="1">Binder</Item> </Items> </Customer> XML Structure – Attributes
  • 35.
    © Raastech, Inc.2017 | All rights reserved. Slide 35 of 61@Raastech  Should you use elements or attributes when designing XML documents? <Customer> <OrderNumber>61237</OrderNumber> <Items> <Item quantity="1">Binder</Item> </Items> </Customer> <Customer OrderNumber="61237"> <Items> <Item quantity="1">Binder</Item> </Items> </Customer> XML Structure – Attributes vs. Elements
  • 36.
    © Raastech, Inc.2017 | All rights reserved. Slide 36 of 61@Raastech  Namespaces are identifiers. <Customers> <e:Customer xmlns:e="http://raastech.com/Employees"> <e:Name>John Doe</e:Name> </e:Customer> <p:Customer xmlns:p="http://raastech.com/Partners"> <p:Name>Jane Doe</p:Name> </p:Customer> <Customers> XML Structure – Namespaces
  • 37.
    © Raastech, Inc.2017 | All rights reserved. Slide 37 of 61@Raastech  Default namespace; no need to prefix all child elements. <Customer xmlns="http://raastech.com/Employees"> <Name>John Doe</Name> </Customer> XML Structure – Default Namespace
  • 38.
    © Raastech, Inc.2017 | All rights reserved. Slide 38 of 61@Raastech  XML Schema defines elements in an XML document.  XML Schema defines attributes in an XML document.  XML Schema defines child elements, and optionally their number and order.  XML Schema defines data types for both elements and attributes.  XML Schema defines default and fixed values for elements and attributes. Introduction to XML Schema
  • 39.
    © Raastech, Inc.2017 | All rights reserved. Slide 39 of 61@Raastech  XML Schemas are well-formed XML documents and are extensible.  They are typically saved as .xsd files.  The root element of every XML Schema is the <schema> element.  The <schema> element may include attributes such as the XML namespace. Introduction to XML Schema
  • 40.
    © Raastech, Inc.2017 | All rights reserved. Slide 40 of 61@Raastech <?xml version="1.0"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified"> <xs:element name="Customer"> <xs:complexType> <xs:sequence> <xs:element name="OrderNumber" type="xs:string"/> <xs:element name="Name" type="xs:string"/> </xs:sequence> </xs:complexType> </xs:element> </xs:schema> Example of an XML Schema
  • 41.
    © Raastech, Inc.2017 | All rights reserved. Slide 41 of 61@Raastech  A simple element contains only plain text that can be defined in one of several predefined data types (or custom types).  The predefined data types in XML Schema include:  string  decimal  integer  boolean  date  time Simple Element
  • 42.
    © Raastech, Inc.2017 | All rights reserved. Slide 42 of 61@Raastech  String <someelement>Hello World</someelement>  Decimal <someelement>12.50</someelement>  Integer <someelement>12</someelement>  Boolean <someelement>true</someelement> Data Types
  • 43.
    © Raastech, Inc.2017 | All rights reserved. Slide 43 of 61@Raastech  Date <someelement>2002-09-24Z</someelement> <someelement>2008-07-24-06:00</someelement>  Time <someelement>08:00:00</someelement>  DateTime <someelement>2008-07-24T08:00:00</someelement> Data Types
  • 44.
    © Raastech, Inc.2017 | All rights reserved. Slide 44 of 61@Raastech  Restrictions are also referred to as facets.  Examples include:  minInclusive  maxInclusive  Enumeration  fractionDigits  Length  maxInclusive  maxExclusive  maxLength  minLength  totalDigits Restrictions
  • 45.
    © Raastech, Inc.2017 | All rights reserved. Slide 45 of 61@Raastech  Complex elements are XML elements that contains other elements or attributes. <xs:element name="Customer"> <xs:complexType> <xs:sequence> <xs:element name="Name" type="xs:string"/> <xs:element name="Item" type="xs:ItemType" minOccurs="1" maxOccurs="5"/> </xs:sequence> </xs:complexType> </xs:element> <xs:complexType name="ItemType"> <xs:sequence> <xs:element name="Item" type="xs:string"/> <xs:element name="Price" type="xs:decimal"/> </xs:sequence> </xs:complexType> Complex Element
  • 46.
    © Raastech, Inc.2017 | All rights reserved. Slide 46 of 61@Raastech  SOAP stands for Simple Object Access Protocol.  It is a communication protocol and allows XML documents to be exchange over HTTP.  As a result, it is platform and technology independent, and ideal for Internet-based communication.  A SOAP message is an XML document that contains the following:  Envelope  Header  Body  Fault Introduction to SOAP
  • 47.
    © Raastech, Inc.2017 | All rights reserved. Slide 47 of 61@Raastech  Envelope  Root element of a SOAP message.  xmlns:soap namespace should always have the value of http://www.w3.org/2001/12/soap-envelope.  Header  Optional.  Could include information such as authentication information.  First child element of the Envelope element.  Body  Required.  Contains the content of the SOAP message (i.e., the payload). SOAP Message
  • 48.
    © Raastech, Inc.2017 | All rights reserved. Slide 48 of 61@Raastech  Example: <?xml version="1.0"?> <soap:Envelope xmlns:soap="http://www.w3.org/2001/12/soap-envelope"> <soap:Header> </soap:Header> <soap:Body> <m:Customer xmlns:m="http://raastech.com/Customer"> <m:Name>John Doe</m:Name> </m:Customer> </soap:Body> </soap:Envelope> SOAP Message
  • 49.
    © Raastech, Inc.2017 | All rights reserved. Slide 49 of 61@Raastech  WSDL stands for Web Services Description Language.  It is an XML document that describes a web service (i.e., it is the interface specification for the web service).  It specifies the location of the web service, the operations it supports, and the message types. Introduction to WSDL
  • 50.
    © Raastech, Inc.2017 | All rights reserved. Slide 50 of 61@Raastech
  • 51.
    © Raastech, Inc.2017 | All rights reserved. Slide 51 of 61@Raastech  A top-down web service begins with a WSDL.  Stubs for the underlying Java classes are created.  Live Development Demo Java Web Service Development: Top-Down WSDL (interface) Java (Class) WSDL (interface) Create interface first Java class stub auto-created Webservice development (top-down)
  • 52.
    © Raastech, Inc.2017 | All rights reserved. Slide 52 of 61@Raastech
  • 53.
    © Raastech, Inc.2017 | All rights reserved. Slide 53 of 61@Raastech  A bottom-up web service begins with an already existing Java class.  Class and methods are easily exposed as a web service interface.  Live Development Demo Java Web Service Development: Bottom-Up Java (class) WSDL (interface) Java (class) WSDL auto-generated from Java class Create Java class first Webservice development (bottom-up)
  • 54.
    © Raastech, Inc.2017 | All rights reserved. Slide 54 of 61@Raastech
  • 55.
    © Raastech, Inc.2017 | All rights reserved. Slide 55 of 61@Raastech  Live Development Demo BPEL Web Service Development
  • 56.
    © Raastech, Inc.2017 | All rights reserved. Slide 56 of 61@Raastech
  • 57.
    © Raastech, Inc.2017 | All rights reserved. Slide 57 of 61@Raastech { "Customer": { "FirstName":"John", "LastName":"Doe" } } <?xml version="1.0"?> <soap:Envelope xmlns:soap="http://www.w3.org/2001/12/soap-envelope"> <soap:Body> <m:Customer xmlns:m="http://raastech.com/Customer"> <m:FirstName>John</m:FirstName> <m:LastName>Doe</m:LastName> </m:Customer> </soap:Body> SOAP/XML Message  Strong message type validation  Based on XML standard  Wide usage and adoption  Not size-friendly:  Size of data: 7 bytes  Size of message: 236 bytes REST/JSON Message  Lightweight and efficient (mobile!)  Growing usage and adoption  Most moving to REST now  Size-friendly:  Size of data: 7 bytes  Size of message: 50 bytes SOAP vs. REST
  • 58.
    © Raastech, Inc.2017 | All rights reserved. Slide 58 of 61@Raastech  http://www.ateam-oracle.com/performance-study-rest-vs-soap-for-mobile-applications/ SOAP vs. REST
  • 59.
    © Raastech, Inc.2017 | All rights reserved. Slide 59 of 61@Raastech  Why has web services become the accepted standard?  Are you more familiar with XML terminology?  What is a popular SOAP client testing tool?  What are the components of a SOAP message?  Can you understand a WSDL when you look at it now?  What is the difference between top-down and bottom-up web service development?  What is REST? Recap
  • 60.
    © Raastech, Inc.2017 | All rights reserved. Slide 60 of 61@Raastech Contact Information  Ahmed Aboulnaga  Technical Director  @Ahmed_Aboulnaga  ahmed.aboulnaga@raastech.com
  • 61.
    © Raastech, Inc.2017 | All rights reserved. Slide 61 of 61@Raastech Q&A