Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

129 lines
3.1 KiB

  1. # ======================================================================
  2. #
  3. # Copyright (C) 2000-2001 Paul Kulchenko ([email protected])
  4. # SOAP::Lite is free software; you can redistribute it
  5. # and/or modify it under the same terms as Perl itself.
  6. #
  7. # $Id: SOAP::Transport::IO.pm,v 0.50 2001/04/18 11:45:14 $
  8. #
  9. # ======================================================================
  10. package SOAP::Transport::IO;
  11. use strict;
  12. use vars qw($VERSION);
  13. $VERSION = '0.50';
  14. use IO::File;
  15. use SOAP::Lite;
  16. # ======================================================================
  17. package SOAP::Transport::IO::Server;
  18. use strict;
  19. use Carp ();
  20. use vars qw(@ISA);
  21. @ISA = qw(SOAP::Server);
  22. sub new {
  23. my $self = shift;
  24. unless (ref $self) {
  25. my $class = ref($self) || $self;
  26. $self = $class->SUPER::new(@_);
  27. }
  28. return $self;
  29. }
  30. sub BEGIN {
  31. no strict 'refs';
  32. my %modes = (in => '<', out => '>');
  33. for my $method (keys %modes) {
  34. my $field = '_' . $method;
  35. *$method = sub {
  36. my $self = shift->new;
  37. return $self->{$field} unless @_;
  38. my $file = shift;
  39. if (defined $file && !ref $file && !defined fileno($file)) {
  40. my $name = $file;
  41. open($file = new IO::File, $modes{$method} . $name) or Carp::croak "$name: $!";
  42. }
  43. $self->{$field} = $file;
  44. return $self;
  45. }
  46. }
  47. }
  48. sub handle {
  49. my $self = shift->new;
  50. $self->in(*STDIN)->out(*STDOUT) unless defined $self->in;
  51. my $in = $self->in;
  52. my $out = $self->out;
  53. my $result = $self->SUPER::handle(join '', <$in>);
  54. no strict 'refs'; print {$out} $result if defined $out;
  55. }
  56. # ======================================================================
  57. 1;
  58. __END__
  59. =head1 NAME
  60. SOAP::Transport::IO - Server side IO support for SOAP::Lite
  61. =head1 SYNOPSIS
  62. use SOAP::Transport::IO;
  63. SOAP::Transport::IO::Server
  64. # you may specify as parameters for new():
  65. # -> new( in => 'in_file_name' [, out => 'out_file_name'] )
  66. # -> new( in => IN_HANDLE [, out => OUT_HANDLE] )
  67. # -> new( in => *IN_HANDLE [, out => *OUT_HANDLE] )
  68. # -> new( in => \*IN_HANDLE [, out => \*OUT_HANDLE] )
  69. # -- OR --
  70. # any combinations
  71. # -> new( in => *STDIN, out => 'out_file_name' )
  72. # -> new( in => 'in_file_name', => \*OUT_HANDLE )
  73. # -- OR --
  74. # use in() and/or out() methods
  75. # -> in( *STDIN ) -> out( *STDOUT )
  76. # -- OR --
  77. # use default (when nothing specified):
  78. # in => *STDIN, out => *STDOUT
  79. # don't forget, if you want to accept parameters from command line
  80. # \*HANDLER will be understood literally, so this syntax won't work
  81. # and server will complain
  82. -> new(@ARGV)
  83. # specify path to My/Examples.pm here
  84. -> dispatch_to('/Your/Path/To/Deployed/Modules', 'Module::Name', 'Module::method')
  85. -> handle
  86. ;
  87. =head1 DESCRIPTION
  88. =head1 COPYRIGHT
  89. Copyright (C) 2000-2001 Paul Kulchenko. All rights reserved.
  90. This library is free software; you can redistribute it and/or modify
  91. it under the same terms as Perl itself.
  92. =head1 AUTHOR
  93. Paul Kulchenko (paulclinger@yahoo.com)
  94. =cut