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

6199Boolean behaviour

Expand Messages
  • Mark Knoop
    Aug 22, 2008
    • 0 Attachment
      Hi

      I'm sure I have read something about this but now I can't find it.

      Take the following example:

      #######################

      use strict;
      use SOAP::Transport::HTTP;

      SOAP::Transport::HTTP::CGI
      -> dispatch_to('MySOAP')
      -> handle;

      package MySOAP;

      sub getTrue {

      my $result = {
      descption => 'Test Boolean Behaviour - True',
      value => 'true',
      };

      return $result;

      }


      sub getFalse {

      my $result = {
      descption => 'Test Boolean Behaviour - False',
      value => 'false',
      };

      return $result;

      }

      1;

      ########################

      When I call the function getTrue() function I get

      <?xml version="1.0" encoding="UTF-8"?><soap:Envelope
      xmlns:xsi="http://www.w3.or
      g/2001/XMLSchema-instance"
      xmlns:soapenc="http://schemas.xmlsoap.org/soap/encodi
      ng/" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
      soap:encodingStyle="http://sch
      emas.xmlsoap.org/soap/encoding/"
      xmlns:soap="http://schemas.xmlsoap.org/soap/env
      elope/"><soap:Body><getTrueResponse
      xmlns="http://soapdev.g-box.tv/MySOAP"><s-ge
      nsym3><value xsi:type="xsd:boolean">true</value><descption
      xsi:type="xsd:string"
      >Test Boolean Behaviour -
      >True</descption></s-gensym3></getTrueResponse></soap:B
      ody></soap:Envelope>

      where description has become a string but value is a boolean with a value
      true as one would expect.

      However when I call getFalse() I get

      <?xml version="1.0" encoding="UTF-8"?><soap:Envelope
      xmlns:xsi="http://www.w3.or
      g/2001/XMLSchema-instance"
      xmlns:soapenc="http://schemas.xmlsoap.org/soap/encodi
      ng/" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
      soap:encodingStyle="http://sch
      emas.xmlsoap.org/soap/encoding/"
      xmlns:soap="http://schemas.xmlsoap.org/soap/env
      elope/"><soap:Body><getFalseResponse
      xmlns="http://soapdev.g-box.tv/MySOAP"><s-g
      ensym3><value xsi:type="xsd:boolean">true</value><descption
      xsi:type="xsd:string
      ">Test Boolean Behaviour -
      False</descption></s-gensym3></getFalseResponse></soa
      p:Body></soap:Envelope>

      where value is still a boolean but still true.

      Can anyone explain how boolean conversion should work or where I might be
      going wrong? My client code is as follows:

      ################################

      use strict;

      #use SOAP::Lite;
      use SOAP::Lite +trace => [qw(method fault transport dispatch result
      parameters headers objects method fault freeform trace
      debug )];

      my $soap = SOAP::Lite
      -> uri('http://soapdev.g-box.tv/MySOAP')
      -> proxy ('https://soapdev.g-box.tv/demo.pl')
      ;

      {

      my $result = $soap
      ->getTrue()
      ->result;

      while ( my ($key, $value) = each(%$result ) ) {
      print "$key => $value\n";
      }
      }

      {

      my $result = $soap
      ->getFalse()
      ->result;

      while ( my ($key, $value) = each(%$result ) ) {
      print "$key => $value\n";
      }
      }

      ###########################

      TIA

      Mark
    • Show all 3 messages in this topic