| 1 | #!/usr/bin/perl -w
|
|---|
| 2 | use 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 |
|
|---|
| 18 | use SOAP::Transport::TCP qw(trace);
|
|---|
| 19 | use 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 |
|
|---|
| 34 | my $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
|
|---|
| 50 | sub show_read {
|
|---|
| 51 | print $/,'## read ##',$/;
|
|---|
| 52 | print Dumper($_[0]);
|
|---|
| 53 | }
|
|---|
| 54 |
|
|---|
| 55 | # show outgoing xml
|
|---|
| 56 | sub 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 | ################################################################################
|
|---|
| 68 | package SOAP_Example_Server;
|
|---|
| 69 |
|
|---|
| 70 | sub echoString {
|
|---|
| 71 | return $_[1] x 2;
|
|---|
| 72 | }
|
|---|
| 73 |
|
|---|
| 74 | 1;
|
|---|