Norret has asked for the wisdom of the Perl Monks concerning the following question:

Hi everyone! I've implemented a SOAP Perl server for rpc/encoded SOAP messages. My client was a C# application, everything worked fine, till I had to use document/literal SOAP messages. So I created a new WSDL file in document/literal style using the package WSDL::Generator. On the server side I use SOAP::Transport::HTTP; to dispatch the SOAP Query to the correct function. My problem now is, that the SOAP message from the C# client arrives at the server, but without the parameters. I hardly searched google for a tutorial with document/literal message, but can't find anything useful. To make it clearer, I will attach some source:
Client (C#)
static void Main(string[] args) { try { ProxyLicenceService service = new ProxyLicenceService( +); string licence = service.generateProxyLicence("blubb") +; Console.WriteLine(licence); } catch (Exception e) { Console.WriteLine(e.Message); } }
Server (Perl):
SOAP::Transport::HTTP::CGI -> dispatch_to('proxyLicenceService') -> handle; package proxyLicenceService; =begin WSDL =cut sub generateProxyLicenceRequest { #my @params = split(/;/,$_[1]); my $test = $_[1]; system("echo $test >> C:\\www\\htdocs\\cgi-bin\\test.log"); }
$_ [0 ] contains the name of the package
$_ [1 ] is empty, but should contain "blubb" :(

Thanks for your help!

Replies are listed 'Best First'.
Re: SOAP document/literal Server
by Anonymous Monk on Oct 29, 2009 at 16:48 UTC
    This is all of SOAP::Transport::HTTP::CGI, try inserting some debug statements :)
    package SOAP::Transport::HTTP::CGI; use vars qw(@ISA); @ISA = qw(SOAP::Transport::HTTP::Server); sub DESTROY { SOAP::Trace::objects('()') } sub new { my $self = shift; return $self if ref $self; my $class = ref($self) || $self; $self = $class->SUPER::new(@_); SOAP::Trace::objects('()'); return $self; } sub make_response { my $self = shift; $self->SUPER::make_response(@_); } sub handle { my $self = shift->new; my $length = $ENV{'CONTENT_LENGTH'} || 0; my $chunked = ( $ENV{'HTTP_TRANSFER_ENCODING'} =~ /^chunked.*$/ ) +|| 0; my $content = q{}; if ($chunked) { my $buffer; binmode(STDIN); while ( read( STDIN, my $buffer, 1024 ) ) { $content .= $buffer; } $length = length($content); } if ( !$length ) { $self->response( HTTP::Response->new(411) ) # LENGTH REQUIR +ED } elsif ( defined $SOAP::Constants::MAX_CONTENT_SIZE && $length > $SOAP::Constants::MAX_CONTENT_SIZE ) { $self->response( HTTP::Response->new(413) ) # REQUEST ENTITY T +OO LARGE } else { if ( exists $ENV{EXPECT} && $ENV{EXPECT} =~ /\b100-Continue\b/ +i ) { print "HTTP/1.1 100 Continue\r\n\r\n"; } #my $content = q{}; if ( !$chunked ) { my $buffer; binmode(STDIN); while ( sysread( STDIN, $buffer, $length ) ) { $content .= $buffer; last if ( length($content) >= $length ); } } $self->request( HTTP::Request->new( $ENV{'REQUEST_METHOD'} || '' => $ENV{'SCRIPT_NAME'}, HTTP::Headers->new( map { ( /^HTTP_(.+)/i ? ( $1 =~ m/SOAPACTION/ ) ? ('SOAPAction') : ($1) : $_ ) => $ENV{$_} } keys %ENV ), $content, ) ); $self->SUPER::handle; } # imitate nph- cgi for IIS (pointed by Murray Nesbitt) my $status = defined( $ENV{'SERVER_SOFTWARE'} ) && $ENV{'SERVER_SOFTWARE'} =~ /IIS/ ? $ENV{SERVER_PROTOCOL} || 'HTTP/1.0' : 'Status:'; my $code = $self->response->code; binmode(STDOUT); print STDOUT "$status $code ", HTTP::Status::status_message($code) +, "\015\012", $self->response->headers_as_string("\015\012"), "\01 +5\012", $self->response->content; }