XML Compile SOAP Mark Overmeer perlovermeer net What
- Slides: 30
XML: : Compile: : SOAP Mark Overmeer, perl@overmeer. net
What are we doing? XML SUCKS!
What are we doing? XML SUCKS! XML Schemas SUCK even more
What are we doing? XML SUCKS! XML Schemas SUCK even more WSDL & SOAP SUCK the most!
XML: : Compile Avoid the need to know learn XML and Schemas: pure Perl within your program
XML: : Compile Avoid the need to know learn XML and Schemas: pure Perl within your program Pure perl, compliant, complete, validating XML message reading and writing.
XML: : Compile Avoid the need to know learn XML and Schemas: pure Perl within your program Pure perl, compliant, complete, validating XML message reading and writing. Minimal programmer interface, maximum usability.
Reading an XML message use XML: : Compile: : Schema; my $schema = XML: : Compile: : Schema->new($xsdfile); my $reader = $schema->compile(READER => '{ns}local'); my $hash = $reader->($xmlmsg); use Data: : Dumper; print Dumper $hash; {http: //www. w 3. org/2001/XMLSchema}int { schema name-space: any IRI }local. Name
Reading and Writing an XML message use XML: : Compile: : Schema; my $schema = XML: : Compile: : Schema->new($xsdfile); my $reader = $schema->compile(READER => '{ns}local'); my $hash = $reader->($xmlmsg); my $writer = $schema->compile(WRITER => '{ns}local'); my $doc = XML: : Lib. XML: : Document->new('1. 0', 'UTF-8'); my $xml = $writer->($doc, $hash); # partial doc print $xml->to. String;
Compliant? Supports: elements attributes references
Compliant? Supports: elements attributes references sequence choice all group attribute. Group
Compliant? Also supports: simple. Type union list restriction complex. Type simple. Content extension restriction complex. Content extension restriction
Compliant? Also supports: min. Occurs/max. Occurs on elements min. Occurs/max. Occurs on blocks fixed, default on elements and attributes. . .
Compliant? Also supports: min. Occurs/max. Occurs on elements min. Occurs/max. Occurs on blocks fixed, default on elements and attributes. . . any. Attribute substitution. Groups (!)
Compliant? Finally: full name-space support (hidden) element/attribute qualified/unqualified message validating
Oops, schemas are complex The good things: you do not have to understand them really. automatic name-spaces type structures hidden (inheritance etc)
Oops, schemas are complex The good things: you do not have to understand them really. automatic name-spaces type structures hidden (inheritance etc) template generator: print $schema->template(PERL => $type); print $schema->template(XML => $type);
Oops, schemas are complex The good things: you do not have to understand them really. automatic name-spaces type structures hidden (inheritance etc) template generator The bad things: current limitations only name-space based schemas mixed content only via hooks schemas themselves not validated you need a schema to use the module
Simple. Type Schema: <element name=”a” type=”int” /> XML message: <a>42</a> Perl: a => 42
complex. Type Schema: <complex. Type name=”a”> <sequence> <element name=”b” type=”int” /> <element name=”c” type=”int” /> </sequence> </complex. Type> <element name=”d” type=”tns: a” /> XML message: <d><b>42</b><c>11</c></d> Perl: d => { b => 42, c => 11 }
Attributes Schema: <complex. Type name=”a”> <sequence> <element name=”b” type=”int” /> </sequence> <attribute name=”c” type=”int” /> </complex. Type> <element name=”d” type=”tns: a” /> XML message: <d c=” 34”><b>12</b></d> Perl: d => { b => 12, c => 34 }
complex. Type/simple. Content Schema: <complex. Type name=”a”> <simple. Content> <extension base=”string” /> </simple. Content> <attribute name=”c” type=”int” /> </complex. Type> <element name=”d” type=”tns: a” /> XML message: <d c=” 7”>YAPC</d> Perl: d => { _ => 'YAPC', c => 7 }
complex. Type/complex. Content Schema: <complex. Type name=”monger”> <complex. Content> <extension base=”person” /> </complex. Content> <attribute name=”nick” type=”string” /> </complex. Type> <element name=”monger” type=”tns: monger” /> XML message: <monger nick=”Nick”><name>Nick</name></monger> Perl: monger => { nick => 'Nick', name => 'Nick' }
element max. Occurs > 1 Schema: <element name=”ticket” max. Occurs=”unbounded” /> XML message: <ticket>123</ticket> <ticket>324</ticket> Perl: ticket => [ 123, 324 ] undef or ARRAY, always!
element max. Occurs > 1 undef or ARRAY: ticket => undef ticket => [ 42 ] ticket => [ 3, 4, 5] so: if(my $t = $data->{ticket}) { print “tickets: @$tn”; } other XML modules: if(my $t = $data->{ticket}) { my @t = ref $t eq 'ARRAY' ? @$t : $t; print “tickets: @tn”; }
and so on. . . list: union: any: count => [ 'one', 'two' ] limit => 'unbounded' '{ns}local' => XML: : Lib. XML: : Element any. Attribute '{ns}local' => XML: : Lib. XML: : Attr . . . all simply a SCALAR, HASH, or ARRAY except. . .
block max. Occurs > 1 Schema: <sequence max. Occurs=”unbounded”> <element name=”a” type=”int” /> <element name=”b” type=”int” /> </sequence> XML message: <a>3</a><b>4</b> <a>5</a><b>6</b> Perl: ARRAY of HASHes seq_a => [ {a => 3, b => 4} , {a => 5, b => 6} ]
SOAP Pass messages over internet. Payload (all XML) Header for delivery Body with payload Envelope to wrap it up Transport (in application) Query - Answer relation Protocol (HTTP) End-point (server, destination)
SOAP Two kinds of SOAP: “Document” well defined body requires longer Schemas “XML-RPC” interface quick and dirty: no types defined, comes from the code (in Perl not, do problematic) SOAP: : Lite's special Discouraged in SOAP 1. 2
WSDL Group all information required for a SOAP transaction into one XML structure, both message structure and transport details You thought that Schemas were overly complicated? Well. . . Demo time! Switching to browser pages.
- Java soap xml 파싱
- Esd cards contain
- Disadvantages of general loader scheme
- Difference between compile time and runtime
- Compile time polymorphism in c++
- Constructor overloading in java
- Compile time polymorphism in c++
- Contoh soal ekspresi reguler automata
- Triples notation adalah
- Qt arm cross compile
- Runtime vs compile time
- 툴체인이란
- Build linux kernel with clang
- Asp.net soap
- Mark kenyon net worth
- Achmed lach net
- Ado.net vb.net
- Soap wsdl uddi
- Undefined simple or complex type 'soapenc:array'
- Soap formation reaction
- Understanding soap
- Problem-oriented charting example
- Caigee
- What are the 11 criteria for lupus
- How does soap work
- Emulsion examples
- Soap organic chemistry
- Protocol
- Is soap acid or base
- Soap brain md
- Rest v soap