1 / 15

XML and SOAP Examples

CERN April 1 2003 Grid Tutorial. XML and SOAP Examples. PTLIU Laboratory for Community Grids Geoffrey Fox, Marlon Pierce Computer Science, Informatics, Physics Indiana University, Bloomington IN 47404. gcf@indiana.edu. A Sample of XML. <?xml version="1.0"?>

dmilo
Download Presentation

XML and SOAP Examples

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


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

  2. A Sample of XML • <?xml version="1.0"?> • <okcversion="3"xmlns="http://grids.ucs.indiana.edu/okc/schema/admin/ver/3"> • <event> • <comment> This is a Test </comment> • <senderemail="gcf@grids.ucs.indiana.edu">Geoffrey Fox</sender> • <distribution> Community Grids Project Reports </distribution> • <organization></organization> • <updatecreateuri="gxos://okc/newsgroups/cgreports/$next“ /> • <keywords></keywords> • <subject></subject> • <message/> • <filingdate> 2/6/2002 </filingdate> • <cg:messageTypexmlns:cg=“http://grids.ucs.indiana.edu/okc/schema/cg/ver/1”> • Test </cg:messageType> • </event> • </okc> Schema are here http://grids.ucs.indiana.edu/schemas/commgrids-v1.xsdhttp://grids.ucs.indiana.edu/schemas/okc-v3.xsd

  3. HTTP Delivery with address 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://xml.apache.org/soap/faq/faq_chawke_smtp.html http://www.w3c.org/2000/xp/Group/1/11/16/soap12-primer.html#SMTP

  4. 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 End HeaderStart Body

  5. SOAP Example (Concluded) Start Body • This has the SOAP Body with actual request End BodyEnd Envelope

  6. SOAP Binding to SMTPfrom W3C • Same example as before • This is very straightforward!

  7. 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, TCP/IP and ATM etc. have their own headers and bodies • It is the standard Russian Dollsituation – each doll has a body (contained inside it) which is the full doll of higher level protocol HTTP SOAP SOAP Body

  8. 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? XML links to MIMEAttachment using absolute or relative URI’s

  9. 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 Specify ls as SOAP Envelope and body

  10. SOAP and Gateway Portal II HTTP Header SOAPEnvelopeand body • And this is the result of ls sent back to client in SOAP over HTTP

  11. <?xml version="1.0" encoding="UTF-8" ?> <definitionsname="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“> WSDL Definitions and Namespaces Default Schema (null namespace) is WSDLsoap namespace is SOAP binding of WSDLtns namespace is this WSDL file xsd namespace defines (ancient) XML Schema

  12. WSDL Message Example <message name="submitRequest"> <part name="xmljob" type="xsd:string"/> </message> <messagename="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.

  13. WSDL portTypes Example <portType name="BatchScriptServicePortType"> <operationname="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.

  14. WSDL SOAP Binding Example <binding name="BatchBinding" type="tns:BatchScriptServicePortType"> <soap:bindingstyle="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> </binding> note binding’s “type” attribute points back to the portType tag by name

  15. 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> </service> </definitions> 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.

More Related