سؤال

I am sending below http request

http://dummyServer.com/cgi-bin/swf/send.cgi?pname=PACKAGENAME&from=FROMADDRESS&to=TOADDRESS

Server is Apache

File : send.cgi

use CGI;
use lib '/Library/WebServer/CGI-Executables/swf/';
use My::XML qw(responce);

my $q = new CGI;
my $pname = $q->param("pname");
my $from = $q->param("from");
my $to = $q->param("to");

responce($pname, $from, $to);

File : My/XML.pm

package My::XML;
use XML::Writer;
use Exporter qw(import);
our @EXPORT_OK = qw(responce);
my $doc = new XML::Writer(DATA_MODE => 'true', DATA_INDENT => 2);

sub responce {
    my ($pname, $from, $to) = @_;
    $doc->startTag("details");
    $doc->dataElement( pname => "${pname}");
    $doc->dataElement( from => "${from}");
    $doc->dataElement( to => "${to}");
    $doc->endTag();
    $doc->end();
}
1;

send.cgi is working fine in cli getting correct xml output. But when i call the above http request i am getting 500 Internal Server. I should get the plain xml displayed on browser window.

Can anyone help in this

هل كانت مفيدة؟

المحلول

You still need to send a proper http header.

print "Content-Type: text/xml\n\n";

Since you're using CGI you can also output it this way:

print $q->header('text/xml');
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top