Title: XML and SOAP Examples
1XML 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
gcf_at_indiana.edu
2A Sample of XML
- lt?xml version"1.0"?gt
- ltokc version"3" xmlns"http//grids.ucs.indiana.e
du/okc/schema/admin/ver/3"gt - lteventgt
- ltcommentgt This is a Test lt/commentgt
- ltsender email"gcf_at_grids.ucs.indiana.edu"gt
Geoffrey Foxlt/sendergt - ltdistributiongt Community Grids Project
Reports lt/distributiongt - ltorganizationgtlt/organizationgt
- ltupdate createuri"gxos//okc/newsgroups/c
greports/next /gt - ltkeywordsgtlt/keywordsgt
- ltsubjectgtlt/subjectgt
- ltmessage/gt
- ltfilingdategt 2/6/2002 lt/filingdategt
- ltcgmessageType xmlnscghttp//grids.ucs
.indiana.edu/okc/schema/cg/ver/1 gt - Test lt/cgmessageTypegt
- lt/eventgt
- lt/okcgt
Schema are here
http//grids.ucs.indiana.edu/schemas/commgrids-v1.
xsdhttp//grids.ucs.indiana.edu/schemas/okc-v3.xs
d
3SOAP 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//xml.apache.org/soap/faq/faq_chawke_smtp.htm
l http//www.w3c.org/2000/xp/Group/1/11/16/soap12-
primer.htmlSMTP
4SOAP Example from W3C I
- We take November 16 tutorialhttp//www.w3c.org/2
000/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
End HeaderStart Body
5SOAP Example (Concluded)
Start Body
- This has the SOAP Body with actual request
End BodyEnd Envelope
6SOAP Binding to SMTPfrom W3C
- Same example as before
- This is very straightforward!
7Remarks 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, 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 higher level protocol
HTTP
SOAP
SOAP Body
8SOAP 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?
XML links to MIMEAttachment using absolute or
relative URIs
9SOAP 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
Specify ls as
SOAP Envelope and body
10SOAP and Gateway Portal II
HTTP Header
SOAPEnvelopeand body
- And this is the result of ls sent back to client
in SOAP over HTTP
11WSDL Definitions and Namespaces
- lt?xml version"1.0" encoding"UTF-8" ?gt
- ltdefinitions name"BatchScriptService"
- targetNamespace"http//yourserver/BatchScriptSer
vice" - xmlns"http//schemas.xmlsoap.org/wsdl/"
- xmlnssoap"http//schemas.xmlsoap.org/wsdl/soap/
" - xmlnstns"http//yourserver/BatchScriptServi
ce" - xmlnsxsd"http//www.w3.org/1999/XMLSchema
gt -
Default Schema (null namespace) is WSDLsoap
namespace is SOAP binding of WSDLtns namespace
is this WSDL file xsd namespace defines (ancient)
XML Schema
12WSDL Message Example
ltmessage name"submitRequest"gt ltpart
name"xmljob" type"xsdstring"/gt lt/messagegt ltmess
age name"submitResponse"gt ltpart
name"response" type"xsdstring"/gt lt/messagegt
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.
13WSDL portTypes Example
ltportType name"BatchScriptServicePortType"gt
ltoperation name"batchGen"gt ltoutput
message"tnssubmitResponse" name"submitRespon
se"/gt ltinput message"tnssubmitRequest"
name"submitRequest"/gt lt/operationgt
lt/portTypegt
A portType corresponds to a Java class, so if we
compile this WSDL to make client stubs, we will
generate a BatchScriptServiceBinding.java class.
14WSDL SOAP Binding Example
ltbinding name"BatchBinding" type"tnsBatchScript
ServicePortType"gt ltsoapbinding style"rpc"
transport"http//schemas.xmlsoap.org/soap/http"/
gt ltoperation name"batchGen"gt
ltsoapoperation soapAction""/gt ltinputgt
ltsoapbody use"encoded
namespace"urnBatchScriptService"
encodingStyle"http//schemas.xmlso
ap.org/soap/encoding/"/gt lt/inputgt
ltoutputgt ltsoapbody use"encoded"
namespace"urnBatchScriptService encodingStyle
"http//schemas.xmlsoap.org/soap/encoding/"/gt
lt/outputgt lt/operationgt lt/bindinggt
note bindings type attribute points back to
the portType tag by name
15WSDL Ports and Services
ltservice name"BatchScriptService"gt
ltdocumentationgtBS stands for Batch Script
lt/documentationgt ltport binding"BatchBinding
name"BatchPort"gt ltsoapaddress
location "http//yourserver/soap/servlet/rpcrout
er/"/gt lt/portgt lt/servicegt lt/definitionsgt
ports are concrete implementations of portTypes
and point back to a particular 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.