OK learnt my lesson :-)

Here is the module code (only the relevant bit)

package PoxPost; use strict; use LWP::UserAgent; use HTTP::Request::Common; use CGI; use CGI::Carp qw ( fatalsToBrowser ); use XML::Simple; my $esbhost = "http://5.0.10.212:8280/services/"; my $query; ###################################################################### # PostESB ###################################################################### sub PostESB { my $servicename = $_[0]; my $payload = $_[1]; my $userAgent = LWP::UserAgent->new(agent => 'perl post'); my $message = "<tag>".$payload."</tag>"; my $link = $esbhost.$servicename; my $response = $userAgent->request(POST $link, Content_Type => 'application/xml', Content => $message); if ($response->is_success){ return 1; } else{ return 0; } }

Now here is my test code

print "start\n"; $svc = "PRUNE"; $msg = "<job>90099368</job><root>/gpfs/STUDIOS/HQ/</root><version>2</v +ersion>"; PoxPost::PostESB($svc, $msg); print "sent\n";

This test works exactly as expected

Now here is part of the CGI that is called, and which in turn tries to call the above method

#!/usr/bin/perl -w use CGI; use CGI::Carp qw ( fatalsToBrowser ); use File::Basename; use File::Copy; use File::Find; use File::Path; use DBI; use POSIX; use lib "/home/zed/ZLIB"; require "poxpost.pl"; ##################################################### # CGI Initialisation ##################################################### # get the form details my $query = new CGI; HTMLHeader(); umask(0); # check action requested my $action = $query->param("action"); # now call required handler if ($action eq "jobversion"){ JobVersionCreate(); } # end header print qq(</body> </html>); # END ###################################################################### +######## # HTMLHeader # ###################################################################### +######## sub HTMLHeader{ print $query->header( ); print qq(<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" +"DTD/xhtml1-strict.dtd">); print qq(<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" +lang="en"> <head>); print qq(<meta http-equiv="Content-Type" content="text/html; chars +et=utf-8" />); print qq(<link href="/compare/style.css" rel="stylesheet" type="te +xt/css" media="screen" />); print qq(</head> <body>); } ###################################################################### +######## # JobVersionCreate ###################################################################### +######## sub JobVersionCreate{ print "creating job version "; # now send message to prune previous versions $payload = "<job>job</job><root>pathroot</root><version>ver</ver>" +; print "<result>OK</result>"; PoxPost::PostESB("COMPARE_PRUNE", $payload); }

The problem is the call to PostESB. This is where the browser just hangs for several seconds. If I remove this line, it works fine. The test code for the PostESB runs very quick. It is the use within the CGI that is the issue.

I hope that the above gives you enough info

Thx Z

In reply to Re^2: Post within CGI by systemz64
in thread Post within CGI by systemz64

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.