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

Need help decoding SOAP response object

Expand Messages
  • Clark Ritchie
    SOAP newbie here. I apologize for what is probably a dumb question but I wasted the better part of today on this and I m really frustrated. I can see the
    Message 1 of 3 , Oct 14, 2005
    • 0 Attachment
      SOAP newbie here. I apologize for what is probably a
      dumb question but I wasted the better part of today on
      this and I'm really frustrated. I can see the data I
      want, just can't get it into Perl data structures I
      can use.

      I'm struggling with how to interpret the data that
      comes back to me from a web service I am calling on
      the SugarCRM product.

      I can see the data (email_address, user_name) buried
      deep within the XML:

      <?xml version="1.0"
      encoding="ISO-8859-1"?><SOAP-ENV:Envelope
      SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
      xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
      xmlns:xsd="http://www.w3.org/2001/XMLSchema"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
      xmlns:si="http://soapinterop.org/xsd"
      xmlns:tns="http://www.sugarcrm.com/sugarcrm"><SOAP-ENV:Body><ns1:user_listResponse
      xmlns:ns1="http://iwww3.x.com/tools/ziploc"><return
      xsi:type="SOAP-ENC:Array"
      SOAP-ENC:arrayType="tns:user_detail[19]"><item
      xsi:type="tns:user_detail"><email_address
      xsi:type="xsd:string">crm@...</email_address><user_name
      xsi:type="xsd:string">admin</user_name>

      What do I need to do to actually access the individual
      fields?

      This is one of the examples I tried to follow:

      my @resultArray=();
      foreach my $field ($som->valueof('Body'))
      {
      push @resultArray,$field;
      }

      ...but I am not sure how to traverse resultArray.

      DataDumper says it looks like this:
      $VAR1 = {
      'user_listResponse' => {
      'return' => [
      bless( {

      'email_address' => 'crm@...',

      Thanks in advance.
      --Clark






      __________________________________
      Yahoo! Mail - PC Magazine Editors' Choice 2005
      http://mail.yahoo.com
    • Duncan Cameron
      ... From the look of the SOAP response you can access the data directly without using the SOM approach. my $som = $soap- method( ...) ; my $r = $som- result;
      Message 2 of 3 , Oct 15, 2005
      • 0 Attachment
        On 2005-10-14 at 23:50:57 Clark Ritchie wrote:

        >SOAP newbie here. I apologize for what is probably a
        >dumb question but I wasted the better part of today on
        >this and I'm really frustrated. I can see the data I
        >want, just can't get it into Perl data structures I
        >can use.
        >
        >I'm struggling with how to interpret the data that
        >comes back to me from a web service I am calling on
        >the SugarCRM product.
        >
        >I can see the data (email_address, user_name) buried
        >deep within the XML:
        >
        ><?xml version="1.0"
        >encoding="ISO-8859-1"?><SOAP-ENV:Envelope
        >SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
        >xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
        >xmlns:xsd="http://www.w3.org/2001/XMLSchema"
        >xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        >xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
        >xmlns:si="http://soapinterop.org/xsd"
        >xmlns:tns="http://www.sugarcrm.com/sugarcrm"><SOAP-
        >ENV:Body><ns1:user_listResponse
        >xmlns:ns1="http://iwww3.x.com/tools/ziploc"><return
        >xsi:type="SOAP-ENC:Array"
        >SOAP-ENC:arrayType="tns:user_detail[19]"><item
        >xsi:type="tns:user_detail"><email_address
        >xsi:type="xsd:string">crm@...</email_address><user_name
        >xsi:type="xsd:string">admin</user_name>
        >
        >What do I need to do to actually access the individual
        >fields?
        >
        >This is one of the examples I tried to follow:
        >
        >my @resultArray=();
        >foreach my $field ($som->valueof('Body'))
        >{
        > push @resultArray,$field;
        >}
        >...but I am not sure how to traverse resultArray.
        >
        >DataDumper says it looks like this:
        >$VAR1 = {
        > 'user_listResponse' => {
        > 'return' => [
        > bless( {
        >
        >'email_address' => 'crm@...',

        From the look of the SOAP response you can access the data directly
        without using the SOM approach.

        my $som = $soap->method( ...) ;
        my $r = $som->result;

        print "$r->[0]->{user_name}\n";
        print "$r->[0]->{email_address}\n";
        print "$r->[0]->{user_detail}\n";

        The $som->result gives you the <return> element as a refernce to an
        array of hash references.

        Regards
        Duncan
      • Clark Ritchie
        Duncan, Thank you! That is exactly what I needed and it works like a charm. Regards, Clark __________________________________ Yahoo! Mail - PC Magazine
        Message 3 of 3 , Oct 15, 2005
        • 0 Attachment
          Duncan,

          Thank you! That is exactly what I needed and it works
          like a charm.

          Regards,
          Clark




          __________________________________
          Yahoo! Mail - PC Magazine Editors' Choice 2005
          http://mail.yahoo.com
        Your message has been successfully submitted and would be delivered to recipients shortly.