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

SOM result method yields 0

Expand Messages
  • bjbarleyjuice
    Greetings, I apologise if wrong but I think I ve been through the messages and don t find this. I get a response (array of arrays that contain refs) envelope
    Message 1 of 3 , Oct 10, 2003
    • 0 Attachment
      Greetings,
      I apologise if wrong but I think I've been through the messages and
      don't find this. I get a response (array of arrays that contain refs)
      envelope that gives no hint of error but seems not to generate
      a 'good' SOM (i.e. $som->result returns 0).

      Looking for clues (and referring to flying dragon pg.333) I try to
      create a SOAP::SOM using the response envelope and get Perl
      error: "Can't use string ("<?xml version="1.0" encoding="UT") as an
      ARRAY ref while "strict refs" in use at c:\perl580
      \site\lib/SOAP/Lite.pm line 376, <XML> line 1".

      I suspect something in the xml is derailing the serializer and this
      isn't related to the ->result (is 0) problem. The latter is what I'm
      really interested in, of course.

      Here's here's the abbreviated (removed lot of 'item's) response
      envelope with a couple of lines of code:
      use SOAP::Lite;

      my $xml = qq(<?xml version="1.0" encoding="UTF-8" ?>
      - <SOAP-ENV:Envelope xmlns:SOAP-
      ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:SOAP-
      ENC="http://schemas.xmlsoap.org/soap/encoding/"
      xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance"
      xmlns:xsd="http://www.w3.org/1999/XMLSchema"
      xmlns:ns1="http://websvc.worldres.com/BookingService">
      - <SOAP-ENV:Body SOAP-
      ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
      - <ns1:prodsearch-ack>
      <errorCode xsi:type="xsd:int">0</errorCode>
      <errorMsg xsi:type="xsd:string">Success</errorMsg>
      - <resp xsi:type="ns1:prodsearch-response">
      - <product-desc xsi:type="ns1:product-desc-array">
      - <item xsi:type="ns1:product-desc">
      <priceId xsi:type="xsd:int">0</priceId>
      <roomTypeId xsi:type="xsd:int">0</roomTypeId>
      <productCode xsi:type="xsd:string">RO</productCode>
      <numAvail xsi:type="xsd:int">0</numAvail>
      <numBed xsi:type="xsd:int">0</numBed>
      <maxSleep xsi:type="xsd:int">0</maxSleep>
      <bedDescription xsi:type="xsd:string" />
      <rateName xsi:type="xsd:string">nal Rate</rateName>
      <rateDescription xsi:type="xsd:string" />
      <roomName xsi:type="xsd:string">Bed /Shower Only</roomName>
      <roomDesc xsi:type="xsd:string" />
      <currencyCode xsi:type="xsd:string" />
      <rateChanges href="#_13" />
      <isEstimate href="#_13" />
      <numNight xsi:type="xsd:int">0</numNight>
      <modifyRelative xsi:type="xsd:int">2</modifyRelative>
      <cancelRelative xsi:type="xsd:int">24</cancelRelative>
      <cancellationPolicyType
      xsi:type="xsd:int">2</cancellationPolicyType>
      <cancellationPolicyValue
      xsi:type="xsd:int">24</cancellationPolicyValue>
      <cancellationPolicyDesc xsi:type="xsd:string">Credit card required
      for guarantee. Cancel 24 hours prior to 4 pm (hotel local time) on
      day of arrival.</cancellationPolicyDesc>
      <commissionPolicyType xsi:type="xsd:int">0</commissionPolicyType>
      <commissionPolicyDesc xsi:type="xsd:string" />
      <guaranteePolicyType xsi:type="xsd:int">2</guaranteePolicyType>
      <guaranteePolicyValue xsi:type="xsd:int">0</guaranteePolicyValue>
      <guaranteePolicyDesc xsi:type="xsd:string" />
      <taxPolicyType xsi:type="xsd:int">2</taxPolicyType>
      <taxPolicyDesc xsi:type="xsd:string">0.46 (Euro) Per Room Per Stay,
      not included in total</taxPolicyDesc>
      <taxInd xsi:type="xsd:int">0</taxInd>
      </item>
      </product-desc>
      </resp>
      </ns1:prodsearch-ack>
      <id id="_13" xsi:type="xsd:boolean">true</id>
      <id id="_26" xsi:type="xsd:boolean">false</id>
      </SOAP-ENV:Body>
      </SOAP-ENV:Envelope>);

      my $som = SOAP::SOM->new($xml);

      #print $som->result;
      print $som->root;
    • Duncan Cameron
      ... Not sure what you mean here. $som- result() will return the value of the first element within the method element. In your case that is the errorCode
      Message 2 of 3 , Oct 10, 2003
      • 0 Attachment
        At 15:20:00 on 2003-10-10 bjbarleyjuice <bjbarleyjuice@...> wrote:

        >Greetings,
        >I apologise if wrong but I think I've been through the messages and
        >don't find this. I get a response (array of arrays that contain refs)
        >envelope that gives no hint of error but seems not to generate
        >a 'good' SOM (i.e. $som->result returns 0).

        Not sure what you mean here.
        $som->result() will return the value of the first element within the method
        element. In your case that is the errorCode element which does indeed have a
        value of 0.

        >Looking for clues (and referring to flying dragon pg.333) I try to
        >create a SOAP::SOM using the response envelope and get Perl
        >error: "Can't use string ("<?xml version="1.0" encoding="UT") as an
        >ARRAY ref while "strict refs" in use at c:\perl580
        >\site\lib/SOAP/Lite.pm line 376, <XML> line 1".

        If you want to create a SOM from some XML you need to do it like this:

        my $som = SOAP::Deserializer->deserialize($xml);

        You can then use the match(), valueof(), dataof() etc. methods to extract
        specific elements.

        Regards
        Duncan
      Your message has been successfully submitted and would be delivered to recipients shortly.