XML and SOAP Examples CERN April 1 2003 Grid Tutorial PTLIU Laboratory for Community Grids Geoffrey Fox, Marlon Pierce Computer Science, Informatics, Physics Indiana University, Bloomington.

Download Report

Transcript XML and SOAP Examples CERN April 1 2003 Grid Tutorial PTLIU Laboratory for Community Grids Geoffrey Fox, Marlon Pierce Computer Science, Informatics, Physics Indiana University, Bloomington.

XML and SOAP Examples
CERN April 1 2003
Grid Tutorial
PTLIU Laboratory for Community Grids
Geoffrey Fox, Marlon Pierce
Computer Science, Informatics, Physics
Indiana University, Bloomington IN 47404
[email protected]
11/6/2015
1
A Sample of XML
















<?xml version="1.0"?>
<okc version="3"
xmlns="http://grids.ucs.indiana.edu/okc/schema/admin/ver/3">
<event>
<comment> This is a Test </comment>
<sender email="[email protected]">Geoffrey Fox</sender>
<distribution> Community Grids Project Reports </distribution>
<organization></organization>
<update createuri="gxos://okc/newsgroups/cgreports/$next“ />
<keywords></keywords>
<subject></subject>
<message/>
<filingdate> 2/6/2002 </filingdate>
<cg:messageType
xmlns:cg=“http://grids.ucs.indiana.edu/okc/schema/cg/ver/1” >
Test </cg:messageType>
Schema are here
</event>
</okc>
http://grids.ucs.indiana.edu/schemas/commgrids-v1.xsd
http://grids.ucs.indiana.edu/schemas/okc-v3.xsd
11/6/2015
2
SOAP over HTTP Structure




SOAP defines a message with
envelope, header and body
The SOAP standard also
defines a binding to HTTP
which is equivalent to
methodology for delivering
message
The SOAP body can specify
data as well as fault
processing information
SOAP can be transported over
standard mail by just putting
XML in body of mail – see
HTTP Delivery with address
http://xml.apache.org/soap/faq/faq_chawke_smtp.html
http://www.w3c.org/2000/xp/Group/1/11/16/soap12-primer.html#SMTP
11/6/2015
3
SOAP Example from W3C I

We take November 16 tutorial:
http://www.w3c.org/2000/xp/Group/1/11/16/soap12-primer.html


This is a SOAP Message – defining a reservation request
Header has key meta-data of application (namelist m: and
instructions to SOAP (intermediate actor) processors
Start Envelope
Start Header
11/6/2015
End Header
Start Body
4
SOAP Example (Concluded)
Start Body

This has the SOAP Body with actual request
11/6/2015
End Body
End Envelope
5
SOAP
Binding to
SMTP
from W3C


Same example as
before
This is very
straightforward!
11/6/2015
6
Remarks on SOAP Structure

If you look at networking protocols, at each layer one
specifies a header and a body
• HTTP has a header telling system where to send information
and some high level specification of what to get
• In example, we see that body of HTTP message is full SOAP
envelope and this envelope has SOAP Header and Body
interpreted by “application”
• At a lower level in protocol stack,
HTTP
SOAP
TCP/IP and ATM etc. have their
own headers and bodies
• It is the standard Russian Doll
situation – each doll has a body
(contained inside it) which is
the full doll of
SOAP Body
higher level protocol
11/6/2015
7
SOAP Attachments


This uses
same
approach as
email or
HTTP and is a
general way of
including
binary data in
XML – but
not
understood by
most parsers!
Very
important?
11/6/2015
XML links to MIME
Attachment using absolute
or relative URI’s
8
SOAP and Gateway Portal I



Having specified service in WSDL, the run-time is
implemented in SOAP which is “just” an XML header
(info needed by transport – empty here) and body
Here is SOAP transported by HTTP message
This is execLocalCommand WSDL operation to run
one particular command (ls) on current WebFlow
directory
HTTP Header
Argument of operation
11/6/2015
ls as
SOAP EnvelopeSpecify
and body
9
HTTP
Header
SOAP
Envelope
and body
SOAP and Gateway
Portal II

11/6/2015
And this is the result
of ls sent back to client
in SOAP over HTTP
10
WSDL Definitions and Namespaces
<?xml version="1.0" encoding="UTF-8" ?>
<definitions name="BatchScriptService"
targetNamespace="http://yourserver/BatchScriptService"
xmlns="http://schemas.xmlsoap.org/wsdl/"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:tns="http://yourserver/BatchScriptService"
xmlns:xsd="http://www.w3.org/1999/XMLSchema“ >
Default Schema (null namespace) is WSDL
soap namespace is SOAP binding of WSDL
tns namespace is this WSDL file
xsd namespace defines (ancient) XML Schema
11/6/2015
11
WSDL Message Example
<message name="submitRequest">
<part name="xmljob" type="xsd:string"/>
</message>
<message name="submitResponse">
<part name="response" type="xsd:string"/>
</message>
For the batch script service, we pass the XML description
of the job as a string and get back the script as a string.
In general, any XML primitive or complex types can be
used in messages.
We could improve our service by defining a BatchScript
complex type.
11/6/2015
12
WSDL portTypes Example
<portType name="BatchScriptServicePortType">
<operation name="batchGen">
<output message="tns:submitResponse"
name="submitResponse"/>
<input message="tns:submitRequest"
name="submitRequest"/>
</operation>
</portType>
A portType corresponds to a Java class, so if we
compile this WSDL to make client stubs, we will
generate a BatchScriptServiceBinding.java class.
11/6/2015
13
WSDL SOAP Binding Example
<binding name="BatchBinding" type="tns:BatchScriptServicePortType">
<soap:binding style="rpc"
transport="http://schemas.xmlsoap.org/soap/http"/>
<operation name="batchGen">
<soap:operation soapAction=""/>
<input>
<soap:body use="encoded“ namespace="urn:BatchScriptService"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</input>
<output>
<soap:body use="encoded" namespace="urn:BatchScriptService“
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</output>
</operation>
note binding’s “type” attribute points back
</binding>
to the portType tag by name
11/6/2015
14
WSDL Ports and Services
<service name="BatchScriptService">
<documentation>BS stands for Batch Script
</documentation>
<port binding="BatchBinding”
name="BatchPort">
<soap:address location=
"http://yourserver/soap/servlet/rpcrouter/"/>
</port>
ports are concrete implementations of
</service>
and point back to a particular
</definitions> portTypes
binding (by name).
They also point to the specific location of a
server that implements the service.
A service is a collection of one or more ports.
11/6/2015
15