Hello, I am very new to Perl and I want to create a Perl web service that accepts a SOAP message, grabs the XML as a text block and saves it in a DB. To do this I created two simple Perl stubs to send an XML doc to a very simple web service. However, I only get an error saying cannot access member in main. I looked this up and only seem to find very generic reasons of which none seem to apply. Below is the very simple code I have written. I am using Strawberry PERL via IIS. Code to send the SOAP message is below. I use a predefined string for the message as I want to swap out many different SOAP messages for testing.

#!perl use HTTP::REQUEST; use LWP::UserAgent; #print "Hello there\n"; my $useragent = LWP::UserAgent->new(agent => 'Perl Post'); my $message = '<?xml version="1.0"?><soap:Envelope xmlns:soap="http:// +localhost"><soap:Header></soap:Header><soap:Body><soap:Method>Demo</s +oap:Method></soap:Body></soap:Envelope>'; my $response = $useragent->post('http://localhost/read_xml.pl',Content +_Type => 'text/xml', Content => $message); print $response->as_string; exit;
My very simplistic server code is below. Again, eventually I want to grab the XML as text but cannot even get it to connect without the error right now. I have also made Demo a class and called it as such but that did not change the error. Any ideas would be appreciated.
#!perl use SOAP::Lite; use SOAP::Transport::HTTP; #print "Content-type: text/plain\n\n"; SOAP::Transport::HTTP::CGI -> dispatch_to('Demo') -> handle; package Demo; print "Content-type: text/plain\n\n"; print "This is a test\n"; my $argument = pop; print "Argument is: $argument\n"; exit;

In reply to Web Service error by chuck882

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.