Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Web Service error

by chuck882 (Initiate)
on Aug 21, 2014 at 13:40 UTC ( [id://1098233]=perlquestion: print w/replies, xml ) Need Help??

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

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;

Replies are listed 'Best First'.
Re: Web Service error
by poj (Abbot) on Aug 21, 2014 at 20:06 UTC
    Try this server program
    #!perl use strict; use SOAP::Transport::HTTP; SOAP::Transport::HTTP::CGI -> dispatch_to('Demo') -> handle; package Demo; sub test { my ($self,$msg) = @_; return "msg : $msg\n"; }
    with this client
    #!perl use SOAP::Lite; print SOAP::Lite -> uri('http://localhost/Demo') -> proxy('http://localhost/read_xml.cgi') -> test('hello server') -> result;
    poj

      I can get that to execute correctly

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://1098233]
Approved by marto
Front-paged by GotToBTru
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (2)
As of 2024-04-26 00:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found