|
< previous index |
SOAP without WSDL |
next > |
|
[describing XML::Compile 0.53, 2007/08/20]
my $soap = XML::Compile::SOAP::SOAP11->new;
my $NS = 'http://example.com/stockquote/schemas';
my $get_price = $soap->compile
( 'CLIENT', 'INPUT'
, header => [ transaction => "{$NS}Transaction" ]
, body => [ request => "{$NS}GetLastTradePrice" ]
, mustUnderstand => 'transaction'
, destination => [ transaction => 'NEXT http://actor' ]
);
The The returned CODE reference will be used on the CLIENT. For the
server, it is an INPUT message, which means that a writer is created.
The Now the application:
my %data_in =
( transaction => 5
, request => {symbol => 'DIS'}
);
# create a XML::LibXML tree
my $xml = $get_price->(\%data_in, 'UTF-8');
print $xml->toString;
The result is:
<SOAP-ENV:Envelope
xmlns:x0="http://example.com/stockquote/schemas"
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Header>
<x0:Transaction
mustUnderstand="1"
actor="http://schemas.xmlsoap.org/soap/actor/next http://actor">
5
</x0:Transaction>
</SOAP-ENV:Header>
<SOAP-ENV:Body>
<x0:GetLastTradePrice>
<symbol>DIS</symbol>
</x0:GetLastTradePrice>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
The "parameter unpack rules" make your live a little easier: my $xml = $get_price->(transaction => 5, symbol => 'DIS'); print $xml->toString; | ||
|
YAPC::EU 2007 Vienna, Presentation of XML::Compile second part, by Mark Overmeer. | ||