[Xml-compile] Excluding Elements From a Web Service Reply
Mark Overmeer
mark at overmeer.net
Thu Oct 13 07:51:38 GMT 2011
* Richard Head Jr. (hsomob1999 at yahoo.com) [111013 00:36]:
> my $resp = $call->($req);
> print 'Result: ', $resp->{params}->reply->data->id
>
> I'd like to write:
> print 'Result: ', $resp->id
> But in the XSD params is an element and not a type so a typemap won't work.
>
> I've also tried hooks fir the params element but they end up either
> wiping out the whole subtree (replace hook) or doing nothing (creating
> an instance of the data class in after hook).
That "params" is on a different level of logic: it's not schema
bassed message processing (where hooks and typemaps can work), but
runtime WSDL interpretation (the "dynamic" name of a message part)
What you can do is: (untested!)
my $call;
{ my $c = $wsdl->compileClient(...);
$call = sub { my ($answer, $trace) = $c->(@_);
bless $answer, SomePackage if $answer;
wantarray ? ($answer, $trace) : $answer;
};
}
print $call->id;
package SomePackage;
sub data() {shift->{params}->reply->data}
sub id() {shift->data->id }
(Cleaner to put the $call constructor in SomePackage as well)
--
Regards,
MarkOv
------------------------------------------------------------------------
Mark Overmeer MSc MARKOV Solutions
Mark at Overmeer.net solutions at overmeer.net
http://Mark.Overmeer.net http://solutions.overmeer.net
More information about the Xml-compile
mailing list