< previous index |
XML::Compile::WSDL |
next > |
Parse the WSDL with the WSDL-Schema. This is everything the Perl programmer needs to do, to get the service to work: use warnings; use strict; use XML::Compile::WSDL (); use Data::Dumper qw/Dumper/; # load the three files (need to start with a WSDL) my $wsdl = XML::Compile::WSDL->new($service); $wsdl->addWSDL($messages); $wsdl->addSchemas($xsd); # first step: find operation my $operation = $wsdl->operation('GetLastTradePrice'); print beautify(Dumper $operation); # see next page # second step: prepare operation my $get_price = $operation->compileClient; # call as often as you like (client) my $answer = $get_price->(tickerSymbol => 'IBM'); print $answer->{body}{price}; When you call the server, you usually pass the information inside a
structure enclosed in the body of the SOAP message. This can be detected
quite automatically, so you do not have to name the part of the message
where the You can also combine steps: my $get_price = $wsdl->compileClient('GetLastTradePrice'); print $get_price->(tickerSymbol => 'IBM')->{body}{price}; The import information in the schemas are not used on purpose: you cannot expect internet to be available (and fast) all the time. So, as the example shows, you will have to specify the definition files by hand. | ||
YAPC::EU 2007 Vienna, Presentation of XML::Compile second part, by Mark Overmeer. |