Loading ...
Sorry, an error occurred while loading the content.

3948MIME::Lite sends XML data, ::HTTP::Apache expects form data?

Expand Messages
  • flarneater
    Sep 27, 2004
    • 0 Attachment
      I'm trying to configure a SOAP server using MIME::Lite. I'm using
      this code on the client side:

      my $sl = SOAP::Lite
      -> proxy( 'http://localhost:7070/soaptest' )
      -> uri( '/soaptest' );

      $sl->Runner( SOAP::Data->name( blotto => 'foobarius' ) );
      print $sl->result, "\n";

      Which generates this request:

      POST http://localhost:7070/soaptest
      Accept: text/xml
      Accept: multipart/*
      Content-Length: 499
      Content-Type: text/xml; charset=utf-8
      SOAPAction: "/soaptest#Runner"

      <?xml version="1.0" encoding="UTF-8"?><SOAP-ENV:Envelope
      xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
      SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
      xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
      xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance"
      xmlns:xsd="http://www.w3.org/1999/XMLSchema"><SOAP-ENV:Body><namesp1:Runner
      xmlns:namesp1="/soaptest"><blotto
      xsi:type="xsd:string">foobarius</blotto></namesp1:Runner></SOAP-ENV:Body></SOAP-ENV:Envelope>

      which in turns generates this result:

      HTTP/1.1 400 Bad Request
      Connection: close
      Date: Mon, 27 Sep 2004 16:36:46 GMT
      Server: Apache/1.3.31 (Unix) mod_perl/1.29
      Content-Type: text/html; charset=iso-8859-1
      Client-Date: Mon, 27 Sep 2004 16:36:46 GMT
      Client-Peer: 155.10.37.51:7070
      Client-Response-Num: 1
      Client-Transfer-Encoding: chunked
      Title: 400 Bad Request
      X-Cache: MISS from localhost

      <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
      <HTML><HEAD>
      <TITLE>400 Bad Request</TITLE>
      </HEAD><BODY>
      <H1>Bad Request</H1>
      Your browser sent a request that this server could not understand.<P>
      [libapreq] unknown content-type: `text/xml; charset=utf-8'<P>
      </BODY></HTML>


      SOAP::Transport::HTTP::Apache is throwing an error when it tries to
      fetch the 'class' paramter from the args passed in the request:

      my %args = $r->args();
      unless (exists $args{class}) {
      return BAD_REQUEST;
      }

      I know the error is occurring here, as I've placed debugging messages
      in the module.

      The server code is this:

      use SOAP::Transport::HTTP::Apache;

      sub handler {
      my $safe_classes = {
      Runner => undef,
      };
      print STDERR "-------SOAP SERVER START -----------\n";
      my $rc = SOAP::Transport::HTTP::Apache->handler($safe_classes);
      print STDERR "-------SOAP SERVER END -----------\n";
      return $rc;
      }

      The two messages are written to the log, but the 'Runner' class is
      never invoked.

      What appears to be happening is that SOAP::Lite is POSTing a XML
      document with a content type of text/xml, whereas ::HTTP::Apache is
      expected form-encoded data (via calling $r->args).

      I've also tried specifying

      $SOAP::Constants::DO_NOT_USE_CHARSET = 1;
      $SOAP::Constants::DO_NOT_CHECK_CONTENT_TYPE = 1;

      but it did not help.

      I'm following the example in the SOAP::Lite docs, so one would assume
      that this worked at one point. What am I doing wrong?

      Many thanks!

      -klm.