1# ======================================================================
2#
3# Copyright (C) 2000-2001 Paul Kulchenko (paulclinger@yahoo.com)
4# SOAP::Lite is free software; you can redistribute it
5# and/or modify it under the same terms as Perl itself.
6#
7# ======================================================================
8
9package SOAP::Transport::IO;
10
11use strict;
12
13our $VERSION = 1.11;
14
15use IO::File;
16use SOAP::Lite;
17# ======================================================================
18
19package SOAP::Transport::IO::Server;
20
21use strict;
22use Carp ();
23use vars qw(@ISA);
24@ISA = qw(SOAP::Server);
25
26sub new {
27    my $class = shift;
28
29    return $class if ref $class;
30    my $self = $class->SUPER::new(@_);
31
32    return $self;
33}
34
35sub in {
36    my $self = shift;
37    $self = $self->new() if not ref $self;
38
39    return $self->{ _in } if not @_;
40
41    my $file = shift;
42    $self->{_in} = (defined $file && !ref $file && !defined fileno($file))
43        ? IO::File->new($file, 'r')
44        : $file;
45    return $self;
46}
47
48sub out {
49    my $self = shift;
50    $self = $self->new() if not ref $self;
51
52    return $self->{ _out } if not @_;
53
54    my $file = shift;
55    $self->{_out} = (defined $file && !ref $file && !defined fileno($file))
56        ? IO::File->new($file, 'w')
57        : $file;
58    return $self;
59}
60
61sub handle {
62    my $self = shift->new;
63
64    $self->in(*STDIN)->out(*STDOUT) unless defined $self->in;
65    my $in = $self->in;
66    my $out = $self->out;
67
68    my $result = $self->SUPER::handle(join '', <$in>);
69    no strict 'refs';
70    print {$out} $result
71        if defined $out;
72    return;
73}
74
75# ======================================================================
76
771;
78
79__END__
80