Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??

I have (mostly) figured out soap::lite. However, I cannot tell anyone as it is a closely guarded secret. ;-)

I say mostly, as I want to generate a document that will have multiple request in it. Take the following code for example:

sub release { my ($args) = @_; # IIS web services expect / as a separator for uri and method. my $lite = SOAP::Lite->new()->on_action(sub { join '/', @_ } ) ->proxy($args->{proxy}), SOAP::Header->name('Authentication' => SOAP::Header->value( SOAP::Header->name('user')->value($zID), SOAP::Header->name('password')->value($zPW))) +; my $response = $lite->call( SOAP::Data->name('release') ->attr({ 'xmlns', $args->{xmlns}}), SOAP::Data->name('request' => \SOAP::Data->value( SOAP::Data->name('actionTime')->value($args->{actio +nTime}), SOAP::Data->name('id')->value($args->{id})->type('l +ong'), SOAP::Data->name('state')->value($args->{state})->t +ype('string'), SOAP::Data->name('result')->value($args->{result})- +>type('string') )), ); return $response; }

This will generate the following XML document:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envel +ope/" xmlns:ns="http://myid.somecompany.net/request/service/3"> <soapenv:Header/> <soapenv:Body> <ns:release> <ns:request> <ns:id>4161</ns:id> <ns:actionTime>2012-09-25T13:26:43.000Z</ns:actionTime> <ns:state>PLACED</ns:state> <ns:result>ACTION_TAKEN</ns:result> </ns:request> </ns:release> </soapenv:Body> </soapenv:Envelope>

My next task is to create an XML document that generated multiple "requests." For example, the following:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envel +ope/" xmlns:ns="http://myid.somecompany.net/request/service/3"> <soapenv:Header/> <soapenv:Body> <ns:release> <ns:request> <ns:id>4161</ns:id> <ns:actionTime>2012-09-25T13:26:43.000Z</ns:actionTime> <ns:state>PLACED</ns:state> <ns:result>ACTION_TAKEN</ns:result> </ns:request> <ns:request> <ns:id>4162</ns:id> <ns:actionTime>2012-09-25T13:26:44.000Z</ns:actionTime> <ns:state>PLACED</ns:state> <ns:result>ACTION_TAKEN</ns:result> </ns:request> </ns:release> </soapenv:Body> </soapenv:Envelope>

I know the magic has to happen in this section of the code:

my $response = $lite->call( SOAP::Data->name('release') ->attr({ 'xmlns', $args->{xmlns}}), SOAP::Data->name('request' => \SOAP::Data->value( SOAP::Data->name('actionTime')->value($args->{actio +nTime}), SOAP::Data->name('id')->value($args->{id})->type('l +ong'), SOAP::Data->name('state')->value($args->{state})->t +ype('string'), SOAP::Data->name('result')->value($args->{result})- +>type('string') )), );

but the question is how? a loop of some sort is, obviously, needed. But where to I put it? The variable that I am using to store the data is an array of hashes. In the above code, I am simply passing a single hash. However, I can always pass the array of hashes.

any help, suggestions, ideas would be appreciated. Thanks, Frank


In reply to More Soap::Lite by fritz1968

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!
  • 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, 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, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • Outside of code tags, you may need to use entities for some characters:
            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.
  • Log In?
    Username:
    Password:

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

    How do I use this? | Other CB clients
    Other Users?
    Others perusing the Monastery: (9)
    As of 2014-11-22 18:10 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      My preferred Perl binaries come from:














      Results (123 votes), past polls