INT-12: Mastering ProDataSets and Native XML Datatypes with Sonic ESB

currygeckoΛογισμικό & κατασκευή λογ/κού

2 Δεκ 2013 (πριν από 3 χρόνια και 6 μήνες)

153 εμφανίσεις

INT
-
12: Mastering ProDataSets and
Native XML Datatypes with Sonic ESB
®

David Cleary

Principal Software Engineer

© 2007 Progress Software Corporation

2


INT
-
12: Mastering ProDataSets and Native XML Datatypes with Sonic ESB

Agenda


Designing Service Interfaces


Weakly
-
typed vs. Strongly
-
typed


Using ProDataSets with Sonic ESB


Using Complex XML with Sonic ESB

© 2007 Progress Software Corporation

3


INT
-
12: Mastering ProDataSets and Native XML Datatypes with Sonic ESB

Products Used


OpenEdge
®

10.1B01


OpenEdge Architect


ProxyGen


OpenEdge Adapter for Sonic ESB
®


OpenEdge Adapter for SonicMQ
®


Sonic Workbench 7.5


SonicMQ


Sonic ESB

© 2007 Progress Software Corporation

4


INT
-
12: Mastering ProDataSets and Native XML Datatypes with Sonic ESB

Problem Overview


OpenEdge Adapter for Sonic ESB doesn’t
support ProDataSets


OpenEdge Adapter for Sonic ESB doesn’t
support “native” XML


<anyType> XML Schema type


Serialized XML != Character data


<tag>
→ &lt;tag&gt;


CBR and transformation services won’t
directly work

© 2007 Progress Software Corporation

5


INT
-
12: Mastering ProDataSets and Native XML Datatypes with Sonic ESB

How it is being solved…


Use LONGCHARs at client and server


Serialize ProDataSets or X
-
Documents to
LONGCHAR


Specify XML Schema string datatype in
interface (WSDL)


ABL Client and server see XML


Sonic services see character data


Write Javascript to double parse data


Extract string data, parse string data

© 2007 Progress Software Corporation

6


INT
-
12: Mastering ProDataSets and Native XML Datatypes with Sonic ESB

There is a Better Way!

© 2007 Progress Software Corporation

7


INT
-
12: Mastering ProDataSets and Native XML Datatypes with Sonic ESB

Designing Interfaces

AppServer

ESB

Adapter

Partner

System

Web

Services

Rest

Packaged
Application

Private

Interface

Public

Interface

Public

Interface

Enterprise Service Bus

© 2007 Progress Software Corporation

8


INT
-
12: Mastering ProDataSets and Native XML Datatypes with Sonic ESB

Designing Interfaces


Web Services vs. REST


Use SOAP when you can leverage tools


Use REST for simplicity


Conform to the Industry Recommendations


Web Services Interoperability Organization (ws
-
i.org)


SOAP Encoding deprecated


use Literal


Use Document instead of RPC for widest client support


Learn WSDL


Create WSDL to conform to interface you want


make
it as simple as possible


it’s the contract

Public Interfaces

© 2007 Progress Software Corporation

9


INT
-
12: Mastering ProDataSets and Native XML Datatypes with Sonic ESB

Designing Interfaces


Interface between Sonic and OpenEdge


Service is one or more related operations


Operations should perform a complete unit of work


make coarse
-
grained for efficiency


All OpenEdge services are Request
-
Reply and can
return a fault


RPC/Literal allows mapping of individual parameters


can use Web Service Invocation Editor easier


Document/Literal allows using transformation of
entire message


Private Interfaces

© 2007 Progress Software Corporation

10


INT
-
12: Mastering ProDataSets and Native XML Datatypes with Sonic ESB

Weakly
-
typed Service Interfaces


Exact data type not specified in interface


Single interface supports multiple
object/entity/data types


Uses XML Schema anyType


Validation done by application


Schema embedded in ProDataSet XML
representation


External schema validation done by
namespace


AutoEdge example of weakly
-
typed interface

© 2007 Progress Software Corporation

11


INT
-
12: Mastering ProDataSets and Native XML Datatypes with Sonic ESB

Strongly
-
typed Service Interfaces


Explicitly defined by XML Schema


Interface supports single object/entity/data
types


Validation should be part of infrastructure


© 2007 Progress Software Corporation

12


INT
-
12: Mastering ProDataSets and Native XML Datatypes with Sonic ESB

The OERA Service Interface

© 2007 Progress Software Corporation

13


INT
-
12: Mastering ProDataSets and Native XML Datatypes with Sonic ESB

The OERA Service Interface


Dynamic service interface


Single interface handles all available services


Weakly typed


ProDataSets represent Business Entities and
Service Context


Schema travels with data


NAMESPACE
-
URI attribute can be used for
identity


Optionally validate against external schema

© 2007 Progress Software Corporation

14


INT
-
12: Mastering ProDataSets and Native XML Datatypes with Sonic ESB

OERA Service Interface in ABL

/* proSIgateway.p


Service interface layer procedure that runs non
-
persistent on the AppServer to feed client requests to
server BEs. */


DEFINE INPUT PARAMETER pcEntityName AS CHARACTER.
DEFINE INPUT PARAMETER pcOpName AS CHARACTER.


DEFINE INPUT
-
OUTPUT PARAMETER DATASET
-
HANDLE phContext.

DEFINE INPUT
-
OUTPUT PARAMETER DATASET
-
HANDLE
phIODataSet.


DEFINE OUTPUT PARAMETER DATASET
-
HANDLE phOutputDataSet.

DEFINE OUTPUT PARAMETER pcExcStatus AS CHARACTER.

© 2007 Progress Software Corporation

15


INT
-
12: Mastering ProDataSets and Native XML Datatypes with Sonic ESB

OERA Service Interface in ABL On ESB

/* proSIgateway.p


Service interface layer procedure that runs non
-
persistent on the AppServer to feed client requests to
server BEs. */


DEFINE INPUT PARAMETER pcEntityName AS CHARACTER.
DEFINE INPUT PARAMETER pcOpName AS CHARACTER.


DEFINE INPUT
-
OUTPUT PARAMETER phContext
AS LONGCHAR
.

DEFINE INPUT
-
OUTPUT PARAMETER phIODataSet
AS LONGCHAR
.


DEFINE OUTPUT PARAMETER phOutputDataSet
AS LONGCHAR
.

DEFINE OUTPUT PARAMETER pcExcStatus AS CHARACTER.

© 2007 Progress Software Corporation

16


INT
-
12: Mastering ProDataSets and Native XML Datatypes with Sonic ESB

Instantiating ProDataSet


from XML


Use the READ
-
XML method on DATASET
HANDLE


Can validate with internal schema


Use NAMESPACE
-
URI attribute to identify


Use READ
-
XMLSCHEMA to do strict
validation

© 2007 Progress Software Corporation

17


INT
-
12: Mastering ProDataSets and Native XML Datatypes with Sonic ESB

Example of ProDataSet Instantiation

DEFINE VARIABLE dsHdl AS HANDLE.


sts = dsHdl:Read
-
XML("LONGCHAR", /* source
-
type */


phContext, /* source of XML */


"EMPTY", /* read
-
mode */


?, /* schema
-
location */


FALSE, /* override mapping*/


?, /* field mapping */


?). /* verify
-
schema
-
mode*/


© 2007 Progress Software Corporation

18


INT
-
12: Mastering ProDataSets and Native XML Datatypes with Sonic ESB

Serializing ProDataSet to XML


Use the WRITE
-
XML method on DATASET
HANDLE


Write schema with Dataset


Can specify minimum schema for non
-
ABL
clients


Use NAMESPACE
-
URI attribute to identify


Default UTF
-
8 encoding preferable


Manually remove XML declaration if inserting
in XML document

© 2007 Progress Software Corporation

19


INT
-
12: Mastering ProDataSets and Native XML Datatypes with Sonic ESB

Example of ProDataSet Serialization

sts = dsHdl:Write
-
XML("LONGCHAR", /* target
-
type */


phContext, /* target for XML */


FALSE, /* formatted XML */


?, /* encoding(UTF
-
8) */


?, /* schema
-
location */


TRUE, /* write
-
schema */


FALSE). /* min
-
schema */

© 2007 Progress Software Corporation

20


INT
-
12: Mastering ProDataSets and Native XML Datatypes with Sonic ESB

Service Interface Demo

© 2007 Progress Software Corporation

21


INT
-
12: Mastering ProDataSets and Native XML Datatypes with Sonic ESB

Creating the Public Interface


Interface created by an ESB Process


Interface is strongly typed (mostly)


Entity and operation are constants


ProDataSets are XML Schema anyType


not
string


Can be messaging
-
based


ABL clients use OpenEdge Adapter for
SonicMQ


Can be SOAP
-
based

© 2007 Progress Software Corporation

22


INT
-
12: Mastering ProDataSets and Native XML Datatypes with Sonic ESB

Messaging
-
based Interfaces


Easier to model


Uses multipart messages


Direct support for TempTable and
ProDataSets in ABL


Provides reliability


Provides true asynchronicity


Good for long running processes


Client interface can be abstracted

© 2007 Progress Software Corporation

23


INT
-
12: Mastering ProDataSets and Native XML Datatypes with Sonic ESB

Message
-
based Demo

© 2007 Progress Software Corporation

24


INT
-
12: Mastering ProDataSets and Native XML Datatypes with Sonic ESB

SOAP
-
based Interface


Harder to model


Really need to work with a single message part


Less reliable (unless you use WS
-
RM)


Synchronous


Long running processes can timeout


Use document/literal SOAP


Widest client support


Takes advantage of Sonic features


Wrap message
-
based process to support both

© 2007 Progress Software Corporation

25


INT
-
12: Mastering ProDataSets and Native XML Datatypes with Sonic ESB

SOAP
-
based Demo

© 2007 Progress Software Corporation

26


INT
-
12: Mastering ProDataSets and Native XML Datatypes with Sonic ESB

Creating Strongly
-
Typed Service Interfaces


Everything defined explicitly in XML Schema


No anyType allowed


XML Namespaces are important


Required for identity


Allows versioning of objects




© 2007 Progress Software Corporation

27


INT
-
12: Mastering ProDataSets and Native XML Datatypes with Sonic ESB

ABL Classes on Sonic ESB


Not supported by WSA or ESB Adapter


Binary representation opaque on bus


Serialization as XML an excellent solution


Take full advantage of ESB services


Easy cross platform/language support (Java
and .Net)

© 2007 Progress Software Corporation

28


INT
-
12: Mastering ProDataSets and Native XML Datatypes with Sonic ESB

XML Serialization of ABL Classes


Create XML Schema representation of class


Use named types


Define elements of those types

© 2007 Progress Software Corporation

29


INT
-
12: Mastering ProDataSets and Native XML Datatypes with Sonic ESB

Example of Customer Record Schema

<xs:schema targetNamespace="
urn:CustomerRecord:0607“
>



<
xs:element name="Customer" type="tns:CustomerType“
/>



<xs:complexType name="CustomerType">


<xs:sequence>


<xs:element name="CustNum"
type="xs:unsignedInt"/>


<xs:element name="Name
">





<xs:element name="Orders">


<xs:complexType>


<xs:sequence>


<
xs:element name="Order"
type="tns:OrderType" minOccurs="0"
maxOccurs="unbounded"
/>


</xs:sequence>


</xs:complexType>

© 2007 Progress Software Corporation

30


INT
-
12: Mastering ProDataSets and Native XML Datatypes with Sonic ESB

Serializing ABL Class to XML


Use SAX
-
WRITER and LONGCHAR


Controlled outside of classes


Classes implement standardized interface


Calls same interface on embedded classes


Ensure you conform to schema

© 2007 Progress Software Corporation

31


INT
-
12: Mastering ProDataSets and Native XML Datatypes with Sonic ESB

Example of Serializing Class


METHOD PUBLIC VOID WriteXML(INPUT saxWriter AS
HANDLE):


saxWriter:START
-
ELEMENT("Customer", xmlNS).




IF pCustNum <> ? THEN DO:




saxWriter:START
-
ELEMENT("CustNum", xmlNS).


saxWriter:WRITE
-
CHARACTERS
(STRING(myCustomer.CustNum)).


saxWriter:END
-
ELEMENT("CustNum", xmlNS).




IF myCustomer.Name <> ? THEN DO:


saxWriter:START
-
ELEMENT("Name", xmlNS).


saxWriter:WRITE
-
CHARACTERS(myCustomer.Name).


saxWriter:END
-
ELEMENT("Name", xmlNS).


END.

.

.

© 2007 Progress Software Corporation

32


INT
-
12: Mastering ProDataSets and Native XML Datatypes with Sonic ESB

Example of Serializing Class

.

.

saxWriter:START
-
ELEMENT("Orders", xmlNS).


FOR EACH myCustOrders:


CAST (orders, order):WriteXML(saxWriter).


END.


saxWriter:END
-
ELEMENT("Orders", xmlNS).

END.


saxWriter:END
-
ELEMENT("Customer", xmlNS).


© 2007 Progress Software Corporation

33


INT
-
12: Mastering ProDataSets and Native XML Datatypes with Sonic ESB

Instantiating Classes from XML


Use X
-
DOCUMENT DOM model


Completely parse and validate data before
class instantiation


Walk the DOM tree


Element node represents class


All element children represent class data or
embedded classes

© 2007 Progress Software Corporation

34


INT
-
12: Mastering ProDataSets and Native XML Datatypes with Sonic ESB

Example of Instantiating a Class


METHOD PUBLIC VOID ReadXML(INPUT xNode AS HANDLE):




/* xNode points at Customer element */


REPEAT i = 1 TO xNode:NUM
-
CHILDREN:


ok = xNode:GET
-
CHILD(xNodeChild, i).


IF NOT OK THEN LEAVE.




cType = xNodeChild:SUBTYPE NO
-
ERROR.


IF cType = "ELEMENT" THEN DO:


nodeName = xNodeChild:LOCAL
-
NAME.


ok = xNodeChild:GET
-
CHILD(xNodeText, 1).


nodeValue = xNodeText:NODE
-
VALUE.


IF nodeName = "CustNum" THEN


/* set CustNum value */


ELSE IF nodeName = "Name" THEN



© 2007 Progress Software Corporation

35


INT
-
12: Mastering ProDataSets and Native XML Datatypes with Sonic ESB

Example of Instantiating a Class

IF nodeName = “Orders” THEN DO:


REPEAT j = 1 TO xNodeChild:NUM
-
CHILDREN:


ok = xNodeChild:GET
-
CHILD(xNodeClass, j).


IF NOT OK THEN LEAVE.




cType = xNodeClass:SUBTYPE NO
-
ERROR.


IF cType = "ELEMENT" THEN DO:


nodeName = xNodeClass:LOCAL
-
NAME.


IF nodeName = “Order" THEN DO:


myOrder = NEW Order().


myOrder:ReadXML(xNodeClass).


END.


END.


END.

END.


© 2007 Progress Software Corporation

36


INT
-
12: Mastering ProDataSets and Native XML Datatypes with Sonic ESB

In Summary


Design your public and private
interfaces


Strongly vs. Weakly typed


SOAP vs. REST


Use XML Namespaces


Never specify string datatype for
XML in public interface

© 2007 Progress Software Corporation

37


INT
-
12: Mastering ProDataSets and Native XML Datatypes with Sonic ESB

ABL Class Demo

© 2007 Progress Software Corporation

38


INT
-
12: Mastering ProDataSets and Native XML Datatypes with Sonic ESB

For More Information, go to…


PSDN


Designing and Deploying SOA Applications
on Sonic ESB for the OpenEdge Developer



Education Courses:


OpenEdge Development with Sonic ESB


Service Oriented Integration with Sonic ESB


Using JMS in OpenEdge


© 2007 Progress Software Corporation

39


INT
-
12: Mastering ProDataSets and Native XML Datatypes with Sonic ESB

Relevant Exchange Sessions


INT
-
12: Mastering ProDataSets and Native
XML Datatypes with Sonic ESB


SONIC
-
1: What’s New in Sonic 7.5


INT
-
3: Realistic Service Oriented
Architecture Approaches


INT
-
7: Middleware Roadmap and Info
Exchange

© 2007 Progress Software Corporation

40


INT
-
12: Mastering ProDataSets and Native XML Datatypes with Sonic ESB

Questions?

© 2007 Progress Software Corporation

41


INT
-
12: Mastering ProDataSets and Native XML Datatypes with Sonic ESB

Thank you for

your time

© 2007 Progress Software Corporation

42


INT
-
12: Mastering ProDataSets and Native XML Datatypes with Sonic ESB