Hello Monks

This is a continuation of last nights question [SOLVED][SOAP::Lite] Obtain request body before request is sent? but I think I need to step back and understand what's going on before moving forward.

First of all, I think what I'm really after is the request envelope. I'd like to be able to print or otherwise store in a variable the XML markup in the envelope. Second of all, I need to modify the HTTP request header (not the XML header as I proposed in the above linked thread). I had my terms mixed up last night but I think I'm starting to understand better.

Anyway. What I'm really after is what happens when you call $client->my_api_method(\%params); where is the XML actually built?

Here is the code I'm working with

<#!/usr/bin/env perl use strict; use warnings; use 5.010; use LWP::UserAgent; use SOAP::Lite; use LWP::Debug; LWP::Debug::level('+'); SOAP::Lite->import(+trace => ' +all'); my $client = SOAP::Lite->proxy($proxy) ->ns($namespace, 'foo') # I'm not sure I understand this. ->uri($uri) ->on_action(sub { sprintf '%s', $_[0] }) ->on_fault(sub { my($soap, $result) = @_; die ref $result ? "Fault Code: " . $result->faultcode . "\n" . "Fault String: " . $result->faultstring . "\n" : $soap->transport->status, "\n"; }); my $params = { foo => 'bar', biz => 'baz'}; #my $data = SOAP::Data->name($params); #my $serial = $client->serializer; #my $xml = $serial->envelope($data); #print Dumper $xml; #my $result = $client->my_api_method($params); my $result = $client->call('my_api_method' => $params);

I've figured out that $client->my_api_method(\%params) is the same as $client->call('my_api_method' => \%params)

When running with trace, it looks like SOAP::Serializer is getting a hash, but when I call $serial->envelope($data) I get an error that it's "Wrong type of envelope (SOAP::Data=HASH(0x8feb78)) for SOAP call". (Of course all the docs point to the SOAP::Serialize docs say that it's used by SOAP::Lite and all the SOAP ::Lite docs say to see SOAP::Serialize... :/ http://search.cpan.org/~kbrown/SOAP-0.28/lib/SOAP/Serializer.pm I've looked at the code for SOAP::Serializer, I'm not convinced it's what's building the XML.)

What modules used by SOAP::Lite actually generate the XML here? I can generate a SOAP::Data hash, but then what do I do with it? I know I can pass it to $client->call so something behind that is generating the xml.

Thanks for the assistance.


In reply to [SOAP::Lite] what happens when I call $client->call('Method', \%params)? by three18ti

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



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.