XML::Compile::SOAP - PowerPoint PPT Presentation

1 / 30
About This Presentation
Title:

XML::Compile::SOAP

Description:

Avoid the need to know learn XML and Schemas: pure Perl within your program ... use Data::Dumper; print Dumper $hash; {http://www.w3.org/2001/XMLSchema}int ... – PowerPoint PPT presentation

Number of Views:58
Avg rating:3.0/5.0
Slides: 31
Provided by: root119
Category:
Tags: soap | xml | compile | dumper

less

Transcript and Presenter's Notes

Title: XML::Compile::SOAP


1
XMLCompileSOAP
Mark Overmeer, perl_at_overmeer.net
2
What are we doing?
  • XML SUCKS!

3
What are we doing?
  • XML SUCKS!
  • XML Schemas SUCK even more

4
What are we doing?
  • XML SUCKS!
  • XML Schemas SUCK even more
  • WSDL SOAP SUCK the most!

5
XMLCompile
  • Avoid the need to know learn XML and Schemas
    pure Perl within your program

6
XMLCompile
  • Avoid the need to know learn XML and Schemas
    pure Perl within your program
  • Pure perl, compliant, complete, validating XML
    message reading and writing.

7
XMLCompile
  • 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.

8
Reading an XML message
  • use XMLCompileSchemamy schema
    XMLCompileSchema-gtnew(xsdfile)my reader
    schema-gtcompile(READER gt 'nslocal')my
    hash reader-gt(xmlmsg)use
    DataDumperprint Dumper hash

http//www.w3.org/2001/XMLSchemaint schema
name-space any IRI localName
9
Reading and Writing an XML message
  • use XMLCompileSchemamy schema
    XMLCompileSchema-gtnew(xsdfile)my reader
    schema-gtcompile(READER gt 'nslocal')my
    hash reader-gt(xmlmsg)
  • my writer schema-gtcompile(WRITER gt
    'nslocal')my doc XMLLibXMLDocument-gt
    new('1.0','UTF-8')my xml writer-gt(doc,
    hash) partial docprint xml-gttoString

10
Compliant?
  • Supports
  • elements
  • attributes
  • references

11
Compliant?
  • Supports
  • elements
  • attributes
  • references
  • sequence
  • choice
  • all
  • group
  • attributeGroup

12
Compliant?
  • Also supports
  • simpleType
  • union
  • list
  • restriction
  • complexType
  • simpleContent
  • extension
  • restriction
  • complexContent
  • extension
  • restriction

13
Compliant?
  • Also supports
  • minOccurs/maxOccurs on elements
  • minOccurs/maxOccurs on blocks
  • fixed, default on elements and attributes
  • ...

14
Compliant?
  • Also supports
  • minOccurs/maxOccurs on elements
  • minOccurs/maxOccurs on blocks
  • fixed, default on elements and attributes
  • ...
  • any
  • anyAttribute
  • substitutionGroups (!)

15
Compliant?
  • Finally
  • full name-space support (hidden)
  • element/attribute qualified/unqualified
  • message validating

16
Oops, schemas are complex
  • The good things you do not have to understand
    them really.
  • automatic name-spaces
  • type structures hidden (inheritance etc)

17
Oops, schemas are complex
  • The good things you do not have to understand
    them really.
  • automatic name-spaces
  • type structures hidden (inheritance etc)
  • template generatorprint schema-gttemplate(PERL
    gt type)print schema-gttemplate(XML gt type)

18
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

19
SimpleType
  • Schemaltelement namea typeint /gt
  • XML messageltagt42lt/agt
  • Perla gt 42

20
complexType
  • SchemaltcomplexType nameagt ltsequencegt
    ltelement nameb typeint /gt ltelement
    namec typeint /gt lt/sequencegtlt/complexType
    gtltelement named typetnsa /gt
  • XML messageltdgtltbgt42lt/bgtltcgt11lt/cgtlt/dgt
  • Perld gt b gt 42, c gt 11

21
Attributes
  • SchemaltcomplexType nameagt ltsequencegt
    ltelement nameb typeint /gt lt/sequencegt
    ltattribute namec typeint /gtlt/complexTypegtlt
    element named typetnsa /gt
  • XML messageltd c34gtltbgt12lt/bgtlt/dgt
  • Perld gt b gt 12, c gt 34

22
complexType/simpleContent
  • SchemaltcomplexType nameagt ltsimpleContentgt
    ltextension basestring /gt
    lt/simpleContentgt ltattribute namec typeint
    /gtlt/complexTypegtltelement named typetnsa
    /gt
  • XML messageltd c7gtYAPClt/dgt
  • Perld gt _ gt 'YAPC', c gt 7

23
complexType/complexContent
  • SchemaltcomplexType namemongergt
    ltcomplexContentgt ltextension baseperson /gt
    lt/complexContentgt ltattribute namenick
    typestring /gtlt/complexTypegtltelement
    namemonger typetnsmonger /gt
  • XML messageltmonger nickNickgtltnamegtNicklt/namegt
    lt/mongergt
  • Perlmonger gt nick gt 'Nick', name gt 'Nick'

24
element maxOccurs gt 1
  • Schemaltelement nameticket maxOccursunbounde
    d /gt
  • XML messageltticketgt123lt/ticketgtltticketgt324lt/tic
    ketgt
  • Perlticket gt 123, 324 undef or ARRAY,
    always!

25
element maxOccurs gt 1
  • undef or ARRAYticket gt undefticket gt 42
    ticket gt 3, 4, 5
  • soif(my t data-gtticket) print
    tickets _at_t\n
  • other XML modulesif(my t data-gtticket)
    my _at_t ref t eq 'ARRAY' ? _at_t t print
    tickets _at_t\n

26
and so on...
  • list count gt 'one', 'two'
  • union limit gt 'unbounded'
  • any 'nslocal' gt XMLLibXMLElement
  • anyAttribute 'nslocal' gt XMLLibXMLAttr
  • ... all simply a SCALAR, HASH, or ARRAYexcept...

27
block maxOccurs gt 1
  • Schemaltsequence maxOccursunboundedgt
    ltelement namea typeint /gt ltelement
    nameb typeint /gtlt/sequencegt
  • XML messageltagt3lt/agtltbgt4lt/bgtltagt5lt/agtltbgt6lt/bgt
  • Perl ARRAY of HASHesseq_a gt a gt 3, b gt
    4 , a gt 5, b gt 6

28
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)

29
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)
  • SOAPLite's special
  • Discouraged in SOAP1.2

30
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.
Write a Comment
User Comments (0)
About PowerShow.com