« Override the root element of the response | Main | Composing messages with raw XML... »

Comments

Paul Yuergens

thanks for the response.

how would i access attributes in a situation like like this where the tags all have the same name?

Joe McTigue

Is there a way to just accept an envelope of information from a non-perl server and read it with soap::lite on the recieving end with out responding? I've been looking through "Web Services with Perl" and can't seem to find any examples, could you help on this?

joe

I'm new to CGI perl and SOAP::Lite and was wondering if anyone could offer some advice on the following code and also whether or not I'd need a client script or not since my application is only to recieve enveloped data and insert it into a data base with out responding to the sending server.
CGI code follows:
#!/usr/bin/perl -wT
######################################################################################
## Script Name: recieve_log.cgi ##
## Date Created: April 23, 2007 ##
## Author: Joseph P. McTigue ##
## Created for: ##
## ##
## Purpose: to accept envelope message from distributed servers and inserts ##
## recieved data into the BU_LOG table of the data base via the ##
## LogToBuLog package. ##
## Accepts: xml formated data envelopes. ##
######################################################################################
use strict;
use CGI ':standard', '-debug';
use lib '/path/to/module/lib';
use SOAP::Transport::HTTP;

my @values;
my @fieldname = ("loglevel","userid","application","message","pid",
"hostname","category","srcfile","line","stack");
my $fieldname = "";
my $valuestr = "";

######################################################################################
######## Get values from Envelope and concatenate into coma delemeted string #########
######################################################################################

my $som = SOAP::Lite
->uri(?) # I have no idea what the next two lines are for if
->proxy(?) # I'm just recieving an envelope from an random server
; # and not responding or sending anything back.

if ( $som->match(SOAP::SOM::envelope) ) {

$som->valueof('Body'); # should give access to body

my $x = 0;
for my $t ($som->valueof('//items')) {
push( @values, $t->{$fieldname[$x]} ); #captures values by xml tags/fieldnames.
$x++;
}

$valuestr = join( "|", @values );

} else {
print "No Body is Home... bad joke I know.\n";
}

if ( $som->fault ) {

die $som->fault->faultstring;
}
######################################################################################
######## Pass delimetedted values in value string to logging_to_BuLog module #########
######## to be parsed and inserted into the BU_LOG table in the DB. #########
######################################################################################
my $logbu = new LogToBuLog;

$results = $logbu->logging_to_BuLog( $valuestr );

if (! $results) {
print "FAILURE!\n\n";
} else {
print "POSSIBLE SUCCESS, check Toad to verify insert made it into DB...\n\n";
}
1;

The comments to this entry are closed.