[Xml-compile] Excluding Elements From a Web Service Reply

Richard Head Jr. hsomob1999 at yahoo.com
Thu Oct 13 00:35:44 GMT 2011


I'm using typemaps for a web service call. The web service reply is wrapped in several redundant elements that require me to create dummy objects (packages) or deal with a top level hash (for the elements that do not have a XSD type). Is there a way to rid the reply of these elements and return only the data I'm interested in?

For example, Instead of:

my $resp = $call->($req);
print 'Result: ', $resp->{params}->reply->data->id

I'd like to write: 
print 'Result: ', $resp->id

Initially I tried something like:

$typemap = { 
  params => sub { 
    my $hash = pop;
    Data->new($hash->{reply}->{data})'
  }
  #...
}

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

Any ideas?



More information about the Xml-compile mailing list