Tuesday, February 12, 2013

SOAP in PHP


See: http://www.perl.com/pub/2001/01/soap.html
SOAP server: server.cgi
#!/usr/bin/perl -w
use SOAP::Transport::HTTP;

SOAP::Transport::HTTP::CGI     
    -> dispatch_to('Demo')       
    -> handle;

package Demo;

sub hi {                       
    return "hello, world\n";       
}

sub languages {                
    return ("Perl", "C", "sh");  
}

SOAP client: client.pl
#!/usr/bin/perl -w
use SOAP::Lite;

$s = SOAP::Lite
    -> uri('http://localhost/Demo')
    -> proxy('http://localhost/DFetch_stamp/tmp/hibye.cgi')
    -> hi()
    -> result; # can use result() too.
print $s;
 
Now run: perl client.pl, you can see the output.

Other notes:
- multiple line comments in perl: start with "=pod", end with "=cut".

No comments:

Blog Archive

Followers