source: branches/feature-module-update/data/module/SOAP/example/tcp_daemon.pl @ 16957

Revision 16957, 1.7 KB checked in by naka, 16 years ago (diff)

PEAR::SOAPモジュールアップ

Line 
1#!/usr/bin/perl -w
2use strict;
3
4=head1 Simple SOAP TCP Server
5
6    Simple SOAP TCP Server with test class (just to check things are working)
7
8    Before you run this test server you will need some perl classes, namely:
9        SOAP::Lite
10        Hook::LexWrap (if you want to see some debugging)
11
12        Flee off to the CPAN if you need them :)
13
14    To run type 'perl <filename>' and if you dont get any errors, it's time
15    to go write some code to connect.
16=cut
17
18use SOAP::Transport::TCP qw(trace);
19use Data::Dumper;
20
21
22#############
23## if you want to see incoming/outgoing raw xml
24## uncomment the following.
25
26#use Hook::LexWrap;
27#wrap *IO::SessionData::read, post => \&show_read;
28#wrap *IO::SessionData::write, post => \&show_write;
29
30##
31#############
32
33
34my $daemon = SOAP::Transport::TCP::Server->new(
35    LocalAddr => '127.0.0.1',
36    LocalPort => '82',
37    Listen    => 5,
38    Reuse     => 1
39);
40
41# dispatch
42$daemon->dispatch_to('SOAP_Example_Server');
43$daemon->handle;
44
45#############
46## callback functions for Hook::LexWrap;
47##
48
49# show incoming xml
50sub show_read {
51    print $/,'## read ##',$/;
52    print Dumper($_[0]);
53}
54
55# show outgoing xml
56sub show_write {
57    print $/,'## write ##',$/;
58    print Dumper($_[0]);
59}
60################################################################################
61
62
63
64################################################################################
65# SOAP_Example_Server
66# Simple test class, method test returns double what you send to it, thats all!
67################################################################################
68package SOAP_Example_Server;
69
70sub echoString {
71    return $_[1] x 2;
72}
73
741;
Note: See TracBrowser for help on using the repository browser.