SAP PI 7.3 Training Material: Page 1 of 153
SAP PI 7.3 Training Material: Page 1 of 153
3 Training Material
Page 1 of 153
Why do we need XML parser?
We need XML parser because we do not want to do everything in our application from scratch, and
we need some "helper" programs or libraries to do something very low-level but very necessary to
us. These low-level but necessary things include checking the well-formedness, validating the
document against its DTD or schema (just for validating parsers), resolving character reference,
understanding CDATA sections, and so on. XML parsers are just such "helper" programs and they
will do all these jobsl. With XML parsers, we are shielded from a lot of these complexicities and we
could concentrate ourselves on just programming at high-level through the API's implemented by the
parsers, and thus gain programming efficiency.
* A DOM parser creates a tree structure in memory from the input document and then waits for
requests from client. But a SAX parser does not create any internal structure. Instead, it takes the
occurrences of components of a input document as events, and tells the client what it reads as it
reads through the input document.
* A DOM parser always serves the client application with the entire document no matter how
much is actually needed by the client. But a SAX parser serves the client application always only with
pieces of the document at any given time.
With DOM parser, method calls in client application have to be explicit and forms a kind of chain.
The DOM interface is perhaps the easiest to understand. It parses an entire XML document and
constructs a complete in-memory representation of the document using the classes modeling the
concepts found in the Document Object Model(DOM) Level 2 Core Specification.
Page 2 of 153
SAX interface
The SAX parser is called the SAXParser and is created by the javax.xml.parsers.SAXParserFactory.
Unlike the DOM parser, the SAX parser does not create an in-memory representation of the XML
document and so is faster and uses less memory. Instead, the SAX parser informs clients of the XML
document structure by invoking callbacks, that is, by invoking methods on a
org.xml.sax.helpers.DefaultHandler instance provided to the parser. This way of accessing document
is called Streaming XML.
The DefaultHandler class implements the ContentHandler, the ErrorHandler, the DTDHandler, and
the EntityResolver interfaces. Most clients will be interested in methods defined in the
ContentHandler interface that are called when the SAX parser encounters the corresponding
elements in the XML document. The most important methods in this interface are:
* startDocument() and endDocument() methods that are called at the start and end of a XML
document.
* startElement() and endElement() methods that are called at the start and end of an document
element.
* characters() method that is called with the text data contents contained between the start and
end tags of an XML document element.
Clients provide a subclass of the DefaultHandler that overrides these methods and processes the
data. This may involve storing the data into a database or writing it out to a stream.
During parsing, the parser may need to access external documents. It is possible to store a local
cache for frequently-used documents using an XML Catalog.
With SAX, some certain methods (usually over ridden by the client) will be invoked automatically
(implicitly) in a way which is called "callback" when some certain events occur. These methods do
not have to be called explicitly by the client, though we could call them explicitly.
Page 3 of 153
Some Text
</FirstElement>
<?some_pi some_attr="some_value"?>
<SecondElement param2="something">
Pre-Text <Inline>Inlined text</Inline> Post-text.
</SecondElement>
</RootElement>
This XML document, when passed through a SAX parser, will generate a sequence of events like the
following:
* XML Element start, named RootElement, with an attribute param equal to "value"
* XML Element start, named FirstElement
* XML Text node, with data equal to "Some Text" (note: text processing, with regard to spaces,
can be changed)
* XML Element end, named FirstElement
* Processing Instruction event, with the target some_pi and data some_attr="some_value"
* XML Element start, named SecondElement, with an attribute param2 equal to "something"
* XML Text node, with data equal to "Pre-Text"
* XML Element start, named Inline
* XML Text node, with data equal to "Inlined text"
* XML Element end, named Inline
* XML Text node, with data equal to "Post-text."
* XML Element end, named SecondElement
* XML Element end, named RootElement
Note that the first line of the sample above is the XML Declaration and not a processing instruction;
as such it will not be reported as a processing instruction event.
The result above may vary: the SAX specification deliberately states that a given section of text may
be reported as multiple sequential text events. Thus in the example above, a SAX parser may
generate a different series of events, part of which might include:
Page 4 of 153
What's the difference between tree-based API and event-based API?
A tree-based API is centered around a tree structure and therefore provides interfaces on
components of a tree (which is a DOM document) such as Document interface,Node interface,
NodeList interface, Element interface, Attr interface and so on. By contrast, however, an event-based
API provides interfaces on handlers. There are four handler interfaces, ContentHandler interface,
DTDHandler interface, EntityResolver interface and ErrorHandler interface.
The main interface involved in SAX is a ContentHandler. You write your own class that implments
this interface. You supply methods to respond to events. One method is called when the document
starts, another when the document ends. One is called when an element starts, one when it ends.
Between these two there may be calls to a "characters" method if there are text character specified
between the start end end tags. If elements are nested, you may get two starts then two ends.
The entire procesing is up to you. The sequence follows the input source. If you don't care about a
specific element when it is processed, do nothing.
When the document end method is called, SAX is finished. Whatever you have kept in whatever
format is all that is kept.
This is in contrast to DOM which reads the entire input and constructs a tree of elements. Then the
tree represents entire source. You can move elements or attributes around to make a different file,
you can run it through a transformer. You can search it using XPath to find sequences of elements
or structures in the document and process them as you wish. When you are done, you can serialize
it (to produce an XML file, or an xml-format stream.
So, SAX is a Simple API for XML as its name implies. It does not have large demands for memory.
You can process a huge file and if you don't want to keep much data, or you are summing data from
the elements that go by, you will not require much memory. DOM builds a tree of Nodes to represent
the entire file. It takes more space to hold an element than it takes for the minimal character
representation -- "<a/>" 4 characters vs. dozens or hundreds.
Both will process the same input, and with SAX, you will see all input as it goes by. You may keep
what you want in whatever format you want. But, if you don't keep it, it is not stored somewhere for
you to process unless you run the input source through SAX again.
Page 5 of 153
Which one is better, SAX or DOM ?
Both SAX and DOM parser have their advantages and disadvantages. Which one is better should
depends on the characteristics of your application (please refer to some questions below).
In the following cases, using SAX parser is advantageous than using DOM parser.
* The input document is too big for available memory (actually in this case SAX is your only
choice)
* You can process the document in small contiguous chunks of input. You do not need the
entire document before you can do useful work
* You just want to use the parser to extract the information of interest, and all your computation
will be completely based on the data structures created by yourself. Actually in most of our
applications, we create data structures of our own which are usually not as complicated as the DOM
tree. From this sense, I think, the chance of using a DOM parser is less than that of using a SAX
parser.
In the following cases, using DOM parser is advantageous than using SAX parser.
* Your application needs to access widely separately parts of the document at the same time.
* Your application may probably use a internal data structure which is almost as complicated
as the document itself.
* Your application has to modify the document repeatedly.
* Your application has to store the document for a significant amount of time through many
method calls.
Assume that an instructor has an XML document containing all the personal information of the
students as well as the points his students made in his class, and he is now assigning final grades
Page 6 of 153
for the students using an application. What he wants to produce, is a list with the SSN and the grades.
Also we assume that in his application, the instructor use no data structure such as arrays to store
the student personal information and the points.
If the instructor decides to give A's to those who earned the class average or above, and give B's
to the others, then he'd better to use a DOM parser in his application. The reason is that he has no
way to know how much is the class average before the entire document gets processed. What he
probably need to do in his application, is first to look through all the students' points and compute the
average, and then look through the document again and assign the final grade to each student by
comparing the points he earned to the class average.
If, however, the instructor adopts such a grading policy that the students who got 90 points or
more, are assigned A's and the others are assigned B's, then probably he'd better use a SAX parser.
The reason is, to assign each student a final grade, he do not need to wait for the entire document to
be processed. He could immediately assign a grade to a student once the SAX parser reads the
grade of this student.
In the above analysis, we assumed that the instructor created no data structure of his own. What
if he creates his own data structure, such as an array of strings to store the SSN and an array of
integers to sto re the points ? In this case, I think SAX is a better choice, before this could save both
memory and time as well, yet get the job done.
Well, one more consideration on this example. What if what the instructor wants to do is not to
print a list, but to save the original document back with the grade of each student updated ? In this
case, a DOM parser should be a better choice no matter what grading policy he is adopting. He does
not need to create any data structure of his own. What he needs to do is to first modify the DOM tree
(i.e., set value to the 'grade' node) and then save the whole modified tree. If he choose to use a SAX
parser instead of a DOM parser, then in this case he has to create a data structure which is almost
as complicated as a DOM tree before he could get the job done.
How does the eventbased parser notice that there is an event happening, since these events
are not like click button or move the mouse?
Clicking a button or moving the mouse could be thought of as events, but events could be thought
of in a more general way. For example, in a switch statement of C, if the switched variable gets some
value, some 'case' will be taken and get executed. At this time, we may also say, one event has
occurred. A SAX parser reads the document character by character or token by token. Once some
Page 7 of 153
patterns (such as the start tag or end tag) are met, it thinks of the occurrences of these patterns as
events and invokes some certain methods overriden by the client.
SAX Parser:
Event based model.
Serial access (flow of events).
Low memory usage (only events are generated).
To process parts of the document (catching relevant events).
To process the document only once.
Backward navigation is not possible as it sequentially processes the document.
Objects are to be created.
DOM Parser:
(Object based)Tree data structure.
Random access (in-memory data structure).
High memory usage (the document is loaded into memory).
To edit the document (processing the in-memory data structure).
To process multiple times (document loaded in memory).
Ease of navigation.
Stored as objects.
Page 8 of 153
Sample document for the example
<?xml version="1.0"?>
<!DOCTYPE shapes [
<!ELEMENT shapes (circle)*>
<!ELEMENT circle (x,y,radius)>
<!ELEMENT x (#PCDATA)>
<!ELEMENT y (#PCDATA)>
<!ELEMENT radius (#PCDATA)>
<!ATTLIST circle color CDATA #IMPLIED>
]>
<shapes>
<circle color="BLUE">
<x>20</x>
<y>20</y>
<radius>20</radius>
</circle>
<circle color="RED" >
<x>40</x>
<y>40</y>
<radius>20</radius>
</circle>
</shapes>
Page 9 of 153
Programs for the Example
program with DOMparser
import java.io.*;
import org.w3c.dom.*;
import org.apache.xerces.parsers.DOMParser;
try{
// create a DOMParser
DOMParser parser=new DOMParser();
parser.parse(args[0]);
Page 10 of 153
color[i]=(String)attrs.getNamedItem("color").getNodeValue();
Page 11 of 153
program with SAXparser
import java.io.*;
import org.xml.sax.*;
import org.xml.sax.helpers.DefaultHandler;
import org.apache.xerces.parsers.SAXParser;
// main method
public static void main(String[] args) {
try{
shapes_SAX SAXHandler = new shapes_SAX (); // an instance of this class
SAXParser parser=new SAXParser(); // create a SAXParser object
parser.setContentHandler(SAXHandler); // register with the ContentHandler
parser.parse(args[0]);
} catch (Exception e) {e.printStackTrace(System.err);} // catch exeptions
}
Page 12 of 153
else if(rawName.equals("y")) // if a y element is seen set the flag as 2
flagY=1;
else if(rawName.equals("radius")) // if a radius element is seen set the flag as 3
flagR=1;
}
Page 13 of 153
line=line+"(x="+x[i]+",y="+y[i]+",r="+r[i]+",color="+color[i]+")";
System.out.println(line);
}
}
Page 14 of 153
DOM versus SAX parsing:
Practical differences are the following
1. DOM APIs map the XML document into an internal tree structure and allows you to refer to the
nodes and the elements in any way you want and as many times as you want. This usually means
less programming and planning ahead but also means bad performance in terms of memory or CPU
cycles.
2. SAX APIs on the other hand are event based ie they traverse the XML document and allows
you to trap the events as it passes through the document. You can trap start of the document, start
of an element and the start of any characters within an element. This usually means more
programming and planning on your part but is compensated by the fact that it will take less memory
and less CPU cycles.
3. DOM performance may not be an issue if it used in a batch environment because the
performance impact will be felt once and may be negligible compared to the rest of the batch process.
4. DOM performance may become an issue in an on line transaction processing environment
because the performance impact will be felt for each and every transaction. It may not be negligible
compared to the rest of the on line processing, since by nature they are short living process.
5. Elapsed time difference in DOM vs SAX
Page 15 of 153
A XML document 13kb long with 2354 elements or tags. This message represents an
accounting G/L entries sent from one Banking system to another.
The significant reduction in under CICS2.2 is due to the fact that the JVM is reusable and it uses
jdk1.3 vs jdk1.1
Page 16 of 153
Introduction EAI Tools
Introduction to SAP Net Weaver 7.1
Modules of SAP Net Weaver 7.1
Overview SAP Process Integration 7.1
Architecture of SAP PI 7.1
Page 17 of 153
Page 18 of 153
Page 19 of 153
Page 20 of 153
Page 21 of 153
Page 22 of 153
Page 23 of 153
Page 24 of 153
Page 25 of 153
Page 26 of 153
Page 27 of 153
Page 28 of 153
System Landscape Directory
Software Catalog
Product and Product Versions
Software Unit
Software Component and its versions
System Catalog
Technical Systems
Business Systems
Page 29 of 153
Page 30 of 153
Page 31 of 153
Page 32 of 153
Page 33 of 153
Page 34 of 153
Page 35 of 153
Page 36 of 153
Page 37 of 153
Integration Builder:
Integration Repository
Importing Software Component Versions
Integration Scenario & Integration Process
Integration Scenario
Actions
Integration Process
Interface Objects
Message Interface (ABAP and Java Proxies)
Message Type
Data Type
Data Type Enhancement
Context Object
External Definition
Mapping Objects
Message Mapping (Graphical Mapping including UDFs)
ABAP Mapping
JAVA Mapping
Interface Mapping
Adapter Objects
Adapter Metadata
Communication Channel Template
Imported Objects
RFCs
IDOCs
Page 38 of 153
Page 39 of 153
Page 40 of 153
Page 41 of 153
Page 42 of 153
What is ESR?
The ES Repository is really the master data repository of service objects for Enterprise SOA
What do we mean by a design time repository?
This refers to the process of designing services
And the ES Repository supports the whole process around contract first or the well known
outside in way of developing services
It provides you with a central modeling and design environment which provides you with all the
tools and editors that enable you to go through this process of service definition
It provides you with the infrastructure to store, manage and version service metadata
Besides service definition, the ES Repository also provides you with a central point for finding
and managing service metadata from different sources
Page 43 of 153
How has ESR Evolved?
The first version of the ES Repository for customers will be the PI based Integration Repository
which is already part of SAP XI 3.0 and SAP NetWeaver 2004s
Customers can be assured that their investments in the Repository are protected because there
will be an upgrade possibility from the existing repository to the Enterprise Services Repository
The ES Repository is of course enhanced with new objects that are needed for defining SAP
process component modeling methodology
The ES Repository in the new release will be available with SAP NetWeaver Process Integration
7.1 and probably also with CE available in the same time frame
The ES Repository is open for customers to create their own objects and extend SAP delivered
objects
Page 44 of 153
DATA Types in 3.0 / 7.0
Page 45 of 153
What is a Message Type?
Page 46 of 153
Data Types in 7.1 have changed / evolved from 7.0 – the following sections illustrate this.
Page 47 of 153
Basic Rules of creating Data Types
Page 48 of 153
Page 49 of 153
What are Data Type Enhancements? What are they used for?
Page 50 of 153
Message Interface in 3.0 / 7.0 -> these have evolved to Service Interface in 7.1
Page 51 of 153
Page 52 of 153
Page 53 of 153
Page 54 of 153
How Service Interface in 7.1 has evolved from Message Interface in 3.0 / 7.0
Page 55 of 153
Page 56 of 153
Page 57 of 153
Page 58 of 153
Page 59 of 153
Page 60 of 153
Page 61 of 153
Interface Mapping in 3.0 / 7.0 has changed to Operations Mapping in 7.1
Page 62 of 153
Page 63 of 153
What does an Integration Scenario do?
Page 64 of 153
Page 65 of 153
BPM or Integration Process
Page 66 of 153
Page 67 of 153
Page 68 of 153
Page 69 of 153
Integration Builder:
Integration Directory
Creating Configuration Scenario
Party
Service without Party
Business System
Communication Channels
Business Service
Integration Process
Receiver Determination
Interface Determination
Sender Agreements
Receiver Agreements
Page 70 of 153
Page 71 of 153
Page 72 of 153
Page 73 of 153
Page 74 of 153
Page 75 of 153
Page 76 of 153
Adapter Communication
Introduction to Adapters
Need of Adapters
Types and elaboration on various Adapters
1. FILE
2. SOAP
3. JDBC
4. IDOC
5. RFC
6. XI (Proxy Communication)
7. HTTP
8. Mail
9. CIDX
10. RNIF
11. BC
12. Market Place
Page 77 of 153
Page 78 of 153
Page 79 of 153
Page 80 of 153
Page 81 of 153
Page 82 of 153
Page 83 of 153
Page 84 of 153
Page 85 of 153
Page 86 of 153
RECEIVER IDOC ADAPTER
Page 87 of 153
Page 88 of 153
Page 89 of 153
Page 90 of 153
Page 91 of 153
Page 92 of 153
Page 93 of 153
Page 94 of 153
Page 95 of 153
Page 96 of 153
Page 97 of 153
Page 98 of 153
Page 99 of 153
Page 100 of 153
Page 101 of 153
Page 102 of 153
Page 103 of 153
Page 104 of 153
Page 105 of 153
Page 106 of 153
Page 107 of 153
Page 108 of 153
Page 109 of 153
Page 110 of 153
Page 111 of 153
Page 112 of 153
Page 113 of 153
Page 114 of 153
PROXIES
Cache Overview
Message Display Tool
Test Tool
Message Monitoring
Component Monitoring
End to End Monitoring
The Enterprise Services Repository containing the design time ES Repository and the
UDDI Services Registry.
A lot of great new functionalities are provided with SAP NetWeaver Process Integration 7.1,
but all are extensions of the robust architecture based on JEE5. And JEE5 promotes less
memory consumption and easier installation
The process integration capabilities within SAP NetWeaver offer the most common ESB
components like
Communication infrastructure (messaging and connectivity)
Request routing and version resolution
Transformation and mapping
Service orchestration
Process and transaction management
Security
Quality of service
Services registry and metadata management
Monitoring and management
Support of Standards (WS RM, WS Security, SAML, BPEL, UDDI, etc.)
Distributed deployment and execution
Publish Subscribe (not covered today)
To summarize these two slides, the main message is that the most important reasons to
use the benefits of the SAP NetWeaver PI
7.1 release are: