Hello,

I'm trying to design a SOAP server using SOAP::Lite (SOAP::Transport::HTTP::Daemon) which should be able to process several requests in the same envelope/message.

The input message looks similar to this:

<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <SOAP-ENV:Body> <m:createRecord xmlns:m="ns://TestSoapServer/SoapServer"> <m:param_1>value_1</m:param_1> <m:param_2>value_2</m:param_2> </m:createRecord> <m:createRecord xmlns:m="ns://TestSoapServer/SoapServer"> <m:param_1>value_3</m:param_1> <m:param_2>value_4</m:param_2> </m:createRecord> </SOAP-ENV:Body> </SOAP-ENV:Envelope>

If the message above is received, then both createRecord requests must be executed. However, my current implementation only executes the first one. I have tried using the ForkOnAccept/ForkAfterProcessing modules but to no avail.

Here is the code I've written:

#!/usr/bin/perl use strict; use warnings; #use SOAP::Transport::HTTP; eval { require SOAP::Transport::HTTP::Daemon::ForkOnAccept } or die << +EOW; $@ WARNING: module for Daemon::ForkOnAccept is not installed by default +. It's in examples/SOAP/Transport/HTTP/ directory you can install it yourself. Feel free to modify it. It's just an example. EOW $SIG{PIPE} = $SIG{INT} = 'IGNORE'; # don't want to die on 'Broken pipe +' or Ctrl-C $SIG{CHLD} = 'IGNORE'; my $Server = SOAP::Transport::HTTP::Daemon::ForkOnAccept -> new (LocalHost => <hostname>, LocalPort => <portnumber>, Listen => 10, Reuse => 1, Timeout => 10) -> serializer(MySerializer->new) -> dispatch_to('SoapServer'); $Server->handle; BEGIN { package SoapServer; use vars qw(@ISA); @ISA = qw(SOAP::Server::Parameters); use SOAP::Lite; sub createRecord { print "createRecord request received...\n"; shift; my $envelope = pop; my $param_1; my $param_2; if ($envelope->match("//createRecord/param_1")) { $param_1 = $envelope->dataof("//createRecord/p +aram_1")->value; } if ($envelope->match("//createRecord/param_2")) { $param_2 = $envelope->dataof("//createRecord/p +aram_2")->value; } print "param_1=$param_1, param_2=$param_2\n"; my $ResponseCode = 0; my $ResponseMessage = "OK"; SOAP::Data->name("m:Response" => SOAP::Data->value( SOAP::Data->name('m:responseCode' => $Respo +nseCode)->type("positiveInteger"), SOAP::Data->name('m:responseCodeDescription' = +> $ResponseMessage)->type("string"))); } } BEGIN { package MySerializer; @MySerializer::ISA = 'SOAP::Serializer'; sub envelope { if( $_[1] =~ /^(?:method|response)$/ ) { $_[2] = SOAP::Data->name("Response")->prefix('m')->uri('ns +://TestSoapServer/SoapServer'); } shift->SUPER::envelope(@_); } }

If I send the SOAP message shown above, I expect the following output:

createRecord request received... param_1=value_1, param_2=value_2 createRecord request received... param_1=value_3, param_2=value_4

Instead, I just get:

createRecord request received... param_1=value_1, param_2=value_2
I am relatively new to SOAP::Lite and SOAP in general, so any help will be much appreciated. Thanks in advance.

In reply to SOAP::Lite server handling multiple requests in the same envelope by atpetkov

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.