Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

How can I suppress that nil attribute using SOAP::Lite, so that my tag looks more like this?

Use a custom serializer

This is sub SOAP::Lite::call

sub call { SOAP::Trace::trace('()'); my $self = shift; die "A service address has not been specified either by using SOAP +::Lite->proxy() or a service description)\n" unless defined $self->proxy && UNIVERSAL::isa($self->proxy => +'SOAP::Client'); $self->init_context(); my $serializer = $self->serializer; $serializer->on_nonserialized($self->on_nonserialized); my $response = $self->transport->send_receive( context => $self, # this is provided for context endpoint => $self->endpoint, action => scalar($self->on_action->($serializer->uriformetho +d($_[0]))), # leave only parameters so we can later update them if + required envelope => $serializer->envelope(method => shift, @_), encoding => $serializer->encoding, parts => @{$self->packager->parts} ? $self->packager->parts + : undef, ); return $response if $self->outputxml; my $result = eval { $self->deserializer->deserialize($response) } if $response; if (!$self->transport->is_success || # transport fault $@ || # not deserializible # fault message even if transport OK # or no transport error (for example, fo TCP, POP3, IO impleme +ntations) UNIVERSAL::isa($result => 'SOAP::SOM') && $result->fault) { return ($self->on_fault->($self, $@ ? $@ . ($response || '') : $result) || $result ); # ? # trick editors } # this might be trouble for connection close... return unless $response; # nothing to do for one-ways # little bit tricky part that binds in/out parameters if (UNIVERSAL::isa($result => 'SOAP::SOM') && ($result->paramsout || $result->headers) && $serializer->signature) { my $num = 0; my %signatures = map {$_ => $num++} @{$serializer->signature}; for ($result->dataof(SOAP::SOM::paramsout), $result->dataof(SO +AP::SOM::headers)) { my $signature = join $;, $_->name, $_->type || ''; if (exists $signatures{$signature}) { my $param = $signatures{$signature}; my($value) = $_->value; # take first value # fillup parameters UNIVERSAL::isa($_[$param] => 'SOAP::Data') ? $_[$param]->SOAP::Data::value($value) : UNIVERSAL::isa($_[$param] => 'ARRAY') ? (@{$_[$param]} = @$value) : UNIVERSAL::isa($_[$param] => 'HASH') ? (%{$_[$param]} = %$value) : UNIVERSAL::isa($_[$param] => 'SCALAR') ? (${$_[$param]} = $$value) : ($_[$param] = $value) } } } return $result; } # end of call()

This is the part that creates the request

envelope => $serializer->envelope(method => shift, @_),

This is an example of using envelope directly Re: Problems with SOAP::Lite client

This is an example of using a custom serializer Re: SOAP::Lite server - changing method name in response

This is an example of bypassing all the SOAP::Lite soap generation and faking it Re^6: checkVat - SOAP::Lite

I would look into using SOAP::Simple (or SOAP::WSDL, XML::Compile ...)


In reply to Re: Suppressing nil attribute in empty SOAP tag by Anonymous Monk
in thread Suppressing nil attribute in empty SOAP tag by ptum

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (7)
As of 2024-03-28 21:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found