agsoba83 has asked for the wisdom of the Perl Monks concerning the following question:

Hi all, first time posting and a newbie to Perl.

I have a this script that's retuning this message

"not well-formed (invalid token) at line 1, column 3, byte 3: Can't connect to "xxxx.xxxx.com:443" ==^

No such host is known. at C:/perl/perl/vendor/lib/LWP/Protocol/http.pm line 47.

at C:/perl/perl/vendor/lib/XML/Parser.pm line 187. (in cleanup) mkdir Temp/:

Permission denied; Access is denied at C:/perl/perl/site/lib/CGI/Session/Driver/file.pm line 34."

here is my code

use strict; use DBI; use CGI::Session; use CGI qw(:standard); my $query = new CGI; print "HTTP/1.0 200 OK\n"; print "Content-type:text/html\n\n\n"; print"<HTML>\n"; print "<Head>\n"; print "<Title>Members</Title>"; print "</Head>\n\n\n"; print"<body>\n"; my $sid = $query->cookie("CGISESSID") || undef; my $session = new CGI::Session(undef, $sid, {Directory=>'Temp/'}); my ($naijaXMLRequest); $naijaXMLRequest = "<Lastbill>"; $naijaXMLRequest .= "<TransactionType>$trans_type</Transaction +Type>"; $naijaXMLRequest .= "<MerchantID>NAIJAMAN009</MerchantID>" +; $naijaXMLRequest .= "<TransactionID>$transaction_id</Transac +tionID>"; $naijaXMLRequest .= "<MemberNum>$mem_number</MemberNum>"; $naijaXMLRequest .= "<apt>$apt</apt>"; $naijaXMLRequest .= "<aptExpMonth>$month</aptExpMonth>"; $naijaXMLRequest .= "<aptExpYear>$year</aptExpYear>"; $naijaXMLRequest .= "<TotalAmountdue>$amount</TotalAmountdue +>"; $naijaXMLRequest .= "</Lastbill>"; my $mem = new LastBill; $mem->sendHTTP( "$gateway", "$naijaXMLRequest" ); $session->delete(); } } print qq[<script type='text/javascript'>window.open('','_self','');win +dow.close()</script>];

I'm running this on Win R12 IIS 8.5. I'll greatly appreciate any help.

Replies are listed 'Best First'.
Re: XML not well-formed (invalid token)
by GrandFather (Saint) on May 02, 2017 at 21:04 UTC

    We can't read your screen from here and your mouse/keyboard are out of our reach so you need to show us enough of your code that we can reproduce the problem. That means stripping your program down to the bare minimum to show the issue. See I know what I mean. Why don't you? for some tips.

    In other news, did it bother you that the text you carefully formatted in the editor is all run together into one nasty unreadable paragraph? How about you go back and edit your node taking note of the advice given above the edit box:
    Use: <p> text here (a paragraph) </p>
    and: <code> code here </code>
    to format your post; it's "PerlMonks-approved HTML":

    Premature optimization is the root of all job security
Re: XML not well-formed (invalid token)
by GrandFather (Saint) on May 03, 2017 at 04:14 UTC

    That script doesn't produce the error you describe. It generates:

    Global symbol "$trans_type" requires explicit package name at noname.p +l line 26. Global symbol "$transaction_id" requires explicit package name at nona +me.pl line 28. Global symbol "$mem_number" requires explicit package name at noname.p +l line 29. Global symbol "$apt" requires explicit package name at noname.pl line +30. Global symbol "$month" requires explicit package name at noname.pl lin +e 31. Global symbol "$year" requires explicit package name at noname.pl line + 32. Global symbol "$amount" requires explicit package name at noname.pl li +ne 33. Global symbol "$gateway" requires explicit package name at noname.pl l +ine 38. Unmatched right curly bracket at noname.pl line 42, at end of line syntax error at noname.pl line 42, near "}" noname.pl has too many errors.

    Maybe you should run the sample code you post before you post it to check that it demonstrates the problem you describe?

    Note that Perl gives you better ways to generate blocks of inline text:

    use strict; use DBI; use CGI::Session; use CGI qw(:standard); my $query = new CGI; print <<HEADER; HTTP/1.0 200 OK\n"; Content-type:text/html <HTML> <Head> <Title>Members</Title> </Head> <body> HEADER my $sid = $query->cookie("CGISESSID") || undef; my $session = new CGI::Session(undef, $sid, {Directory => 'Temp/'}); my $trans_type = 'xxx'; my $transaction_id = 'xxx'; my $mem_number = 'xxx'; my $apt = 'xxx'; my $month = 'xxx'; my $year = 'xxx'; my $amount = 'xxx'; my $naijaXMLRequest = <<XML; <Lastbill>"; <TransactionType>$trans_type</TransactionType>"; <MerchantID>NAIJAMAN009</MerchantID>"; <TransactionID>$transaction_id</TransactionID>"; <MemberNum>$mem_number</MemberNum>"; <apt>$apt</apt>"; <aptExpMonth>$month</aptExpMonth>"; <aptExpYear>$year</aptExpYear>"; <TotalAmountdue>$amount</TotalAmountdue>"; </Lastbill>"; XML my $mem = new LastBill; my $gateway = 'xxx'; $mem->sendHTTP($gateway, "$naijaXMLRequest"); $session->delete(); print qq[<script type='text/javascript'>window.open('','_self','');windo +w.close()</script>];

    and that CGI will generate the header for you using print $cgi->header();.

    Showing us the CGI related code probably isn't relevant to your issue so you could remove that to focus on the real problem you want help with.

    Premature optimization is the root of all job security
Re: XML not well-formed (invalid token)
by AnomalousMonk (Archbishop) on May 02, 2017 at 21:14 UTC
Re: XML not well-formed (invalid token)
by Corion (Patriarch) on May 03, 2017 at 07:22 UTC
    Can't connect to "xxxx.xxxx.com:443

    Your web service cannot connect to the remote end. Verify that you can make the connection using other tools.

    Most likely, this is because of a certificate mismatch. See IO::Socket::SSL on what you can do about it and see ssl-tools for more tools for debugging SSL connection problems.

    There is an easy way to disable all SSL validation and verification but I won't post it here.