Greetings !

I've written a client and server using SOAP::Lite. After days of headaches I've finally managed to add headers and values.

Currently I have a problem. The SOAP envelope generated from the client has a <Action> tag within a <MessengerHeader>, the <Action> contains the type of action, i.e "New Ticket", "Update Ticket", "Close Ticket". What I'm trying to do is, once the server program gets the SOAP envelope, it should check the value within <Action>...</Action> tags and based on the value call a subroutine. The calls to the subroutines will vary according the value within the <Action>tag.

Can anyone let me know how to proceed with this.

Below is the SOAP envelope generated from the Client call
<?xml version="1.0" encoding="UTF-8"?> <SOAP-ENV:Envelope xmlns:xsi="http://www.w3.org/1999/XMLSchema-instanc +e" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/1999/XMLSchema"> <SOAP-ENV:Body> <byName xmlns="Delivery"> <MessengerHeader> <Password>test-password</Password> <Username>Bannu</Username> <Action>New Ticket</Action> <Account>local-account</Account> </MessengerHeader> <TicketInformation> <createStatus>Private</createStatus> <AS>ABC 111 00</AS> <ISPCustomer>N</ISPCustomer> <Embargo>false</Embargo> </TicketInformation> </byName> </SOAP-ENV:Body> </SOAP-ENV:Envelope>

Below is the client code:
#!/usr/local/bin/perl #CLIENT use warnings; use strict; use SOAP::Lite +trace => qw(debug); my $uri = 'Delivery'; #Data to be added to the request my (@data) = ( SOAP::Data->name(MessengerHeader => { Action => "New Tick +et", Username => "Bannu" +, Password => "test-p +assword", Account => "local-a +ccount" } ), SOAP::Data->name(TicketInformation =>{ createStatus => "P +rivate", ISPCustomer => "N" +, AS => "ABC 111 00" +, Embargo=>"false" } ) ); #Enable fault management globally use SOAP::Lite on_fault => sub { my($soap, $res) = @_; eval { die ref $res ? $res->faultstring : $soap->transport->stat +us }; return ref $res ? $res : new SOAP::SOM; }; #print $soap->fault ? $soap->faultstring. "\n" : $soap->result; my $soap = SOAP::Lite -> proxy('http://localhost/perl/soap-dbi.pl') -> serializer($serializer) -> uri($uri); my $res = $soap->byName(@data); #print $soap->retrieveDocument->result; print $res->fault ? $res->faultstring. "\n" : $res->result;

I'm also trying to access the values from the SOAP envelope on the server side,but failing miserably. The following is the server code
#!/usr/local/bin/perl #SERVER use SOAP::Transport::HTTP; my $uri = 'Delivery'; SOAP::Transport::HTTP::CGI -> dispatch_to('Delivery') -> handle; package Delivery; use vars qw(@ISA); @ISA = qw(SOAP::Server::Parameters); sub byName { #Get the headers passed from the client my ($self, $in) = @_; my @input = %{$in}; foreach my $input (@input) { print $self . "==> " . $input, "\n"; } if ($input == 'New Ticket'){ & sendAcknowledgement(); } # send a response based on the <Action> value, currently not working sendAcknowledgement(); sub sendAcknowledgement { my (@response) = ( SOAP::Data->name(Acknowledgement =>{ createStatus => "O +K", Received => "0", } ) ); # use Data::Dumper; # print Dumper(@response); return map { $_ } %{$response}; }
The following is the output from the server:
Delivery==> test-password Delivery==> Action Delivery==> New Ticket Delivery==> Username Delivery==> Bannu Delivery==> Account Delivery==> local-account Status: 200 OK Content-Length: 388 Content-Type: text/xml; charset=utf-8 SOAPServer: SOAP::Lite/Perl/0.60 <?xml version="1.0" encoding="UTF-8"?> <SOAP-ENV:Envelope xmlns:xsi="http://www.w3.org/1999/XMLSchema-instan +ce" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/1999/XMLSchema"> <SOAP-ENV:Body> <byNameResponse xmlns="Delivery"><s-gensym15/></byNameResponse> </SOAP-ENV:Body> </SOAP-ENV:Envelope>

In reply to SOAP - Returning response from Server to Client request based on the <Action> by chanakya

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.