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

SOAP::Lite trying to emulate PHP composed SOAP

Expand Messages
  • yetinother
    I am writing a SOAP client, and I ve been having difficulties using SOAP::Lite to work properly with the supplied service. I have a sample SOAP request, which
    Message 1 of 2 , Apr 6 5:15 AM
    • 0 Attachment
      I am writing a SOAP client, and I've been having difficulties using
      SOAP::Lite to work properly with the supplied service. I have a sample
      SOAP request, which was created using PHP, and I know that it works, so
      I simply need to 'copy' it with perl, in order to get it working,
      right?

      Anyway, this is what the successful PHP-composed SOAP envelope looks
      like:
      <?xml version="1.0" encoding="UTF-8"?>
      <SOAP-ENV:Envelope
      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:ns4="http://www.freshdigital.co.uk/mediastore">
      <SOAP-ENV:Body>
      <ns4:search>
      <ns4:session>$SESSIONID</ns4:session>
      <ns4:searchTerms>
      <ns4:item>
      <ns4:key>ARTISTID</ns4:key>
      <ns4:value>2047</ns4:value>
      <ns4:like>true</ns4:like>
      </ns4:item>
      </ns4:searchTerms>
      <ns4:searchType>OR</ns4:searchType>
      <ns4:offset>0</ns4:offset>
      <ns4:count>50</ns4:count>
      </ns4:search>
      </SOAP-ENV:Body>
      </SOAP-ENV:Envelope>

      (the $SESSIONID bit should actually contain a valid sessionID, which I
      removed for this public posting)
      And the documentation says this about their 'search' functionality.
      requires: sessionid, searchTerms (an array of search criteria),
      searchtype (AND or OR), offset, and count.

      anyway, this is the perl code I used to 'emulate' this SOAP call.

      my @searchterms = (
      SOAP::Data->name("searchTerms" =>
      \SOAP::Data->value(SOAP::Data->name("item" =>
      [

      SOAP::Data->type('string')->name('key')->value('GENRE'),

      SOAP::Data->type('string')->name('value')->value('rock'),

      SOAP::Data->type('boolean')->name('like')->value('true')
      ]
      ))
      )
      );
      my $result = $soap->search( $sessionID, @searchterms, "OR", 0, 10 );

      which results in this SOAP envelope being passed on to the SOAP
      service:

      <?xml version="1.0" encoding="UTF-8"?>
      <SOAP-ENV:Envelope
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
      xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
      xmlns:xsd="http://www.w3.org/2001/XMLSchema"
      SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
      <SOAP-ENV:Body>
      <namesp2:search
      xmlns:namesp2="http://www.freshdigital.co.uk/mediastore">
      <session xsi:type="xsd:string">$SESSIONID</session>
      <searchTerms>
      <item xsi:type="SOAP-ENC:Array"
      SOAP-ENC:arrayType="xsd:anyType[3]">
      <key xsi:type="xsd:string">GENRE</key>
      <value xsi:type="xsd:string">rock</value>
      <like xsi:type="xsd:boolean">true</like>
      </item>
      </searchTerms>
      <searchType xsi:type="xsd:string">OR</searchType>
      <offset xsi:type="xsd:int">0</offset>
      <count xsi:type="xsd:int">10</count>
      </namesp2:search>
      </SOAP-ENV:Body>
      </SOAP-ENV:Envelope>

      (once again, I have changed the real sessionID to $SESSIONID, for
      privacy reasons).
      which, while being more verbose, appears (to me) to be much the same
      thing.
      Unfortunately, I get this (not very useful) error message from the
      service, after submitting the above search request:

      <faultcode>soapenv:Server.userException</faultcode>
      <faultstring>java.lang.ArrayStoreException:
      [Ljava.lang.Object;</faultstring>
      <detail>
      <ns1:hostname
      xmlns:ns1="http://xml.apache.org/axis/">bridgaa2</ns1:hostname>
      </detail>

      So it looks like some kind of problem with the array, but other than
      that, I have no idea what I am doing wrong. Perhaps someone more
      experienced with SOAP can point out my obvious mistake, or what the
      problem may be.

      My apologies if this post has been a bit verbose with the XML, but I
      felt it was necessary in order to figure out the problem.
    • Eric Bridger
      See below. ... I m not sure why you are using two arrays: @searchterms and @item. my $searchterms = S::D- name(searchTerms = S::D- name(item = S::D- value(
      Message 2 of 2 , Apr 6 5:51 AM
      • 0 Attachment
        See below.

        On Thu, 2006-04-06 at 08:15, yetinother wrote:
        > I am writing a SOAP client, and I've been having difficulties using
        > SOAP::Lite to work properly with the supplied service. I have a sample
        > SOAP request, which was created using PHP, and I know that it works, so
        > I simply need to 'copy' it with perl, in order to get it working,
        > right?
        >
        > Anyway, this is what the successful PHP-composed SOAP envelope looks
        > like:
        > <?xml version="1.0" encoding="UTF-8"?>
        > <SOAP-ENV:Envelope
        > 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:ns4="http://www.freshdigital.co.uk/mediastore">
        > <SOAP-ENV:Body>
        > <ns4:search>
        > <ns4:session>$SESSIONID</ns4:session>
        > <ns4:searchTerms>
        > <ns4:item>
        > <ns4:key>ARTISTID</ns4:key>
        > <ns4:value>2047</ns4:value>
        > <ns4:like>true</ns4:like>
        > </ns4:item>
        > </ns4:searchTerms>
        > <ns4:searchType>OR</ns4:searchType>
        > <ns4:offset>0</ns4:offset>
        > <ns4:count>50</ns4:count>
        > </ns4:search>
        > </SOAP-ENV:Body>
        > </SOAP-ENV:Envelope>
        >
        > (the $SESSIONID bit should actually contain a valid sessionID, which I
        > removed for this public posting)
        > And the documentation says this about their 'search' functionality.
        > requires: sessionid, searchTerms (an array of search criteria),
        > searchtype (AND or OR), offset, and count.
        >
        > anyway, this is the perl code I used to 'emulate' this SOAP call.
        >
        > my @searchterms = (
        > SOAP::Data->name("searchTerms" =>
        > \SOAP::Data->value(SOAP::Data->name("item" =>
        > [
        >
        > SOAP::Data->type('string')->name('key')->value('GENRE'),
        >
        > SOAP::Data->type('string')->name('value')->value('rock'),
        >
        > SOAP::Data->type('boolean')->name('like')->value('true')
        > ]
        > ))
        > )
        > );

        I'm not sure why you are using two arrays: @searchterms and @item.

        my $searchterms = S::D->name(searchTerms => \S::D->name(item =>
        \S::D->value(
        S::D->name(key => 'GENRE'),
        S::D->name(value => 'rock'),
        S::D->name(like => 'true')->type('boolean'),
        )
        )
        );


        > my $result = $soap->search( $sessionID, @searchterms, "OR", 0, 10 );
        >
        > which results in this SOAP envelope being passed on to the SOAP
        > service:
        >
        > <?xml version="1.0" encoding="UTF-8"?>
        > <SOAP-ENV:Envelope
        > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        > xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
        > xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
        > xmlns:xsd="http://www.w3.org/2001/XMLSchema"
        > SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
        > <SOAP-ENV:Body>
        > <namesp2:search
        > xmlns:namesp2="http://www.freshdigital.co.uk/mediastore">
        > <session xsi:type="xsd:string">$SESSIONID</session>
        > <searchTerms>
        > <item xsi:type="SOAP-ENC:Array"
        > SOAP-ENC:arrayType="xsd:anyType[3]">
        > <key xsi:type="xsd:string">GENRE</key>
        > <value xsi:type="xsd:string">rock</value>
        > <like xsi:type="xsd:boolean">true</like>
        > </item>
        > </searchTerms>
        > <searchType xsi:type="xsd:string">OR</searchType>
        > <offset xsi:type="xsd:int">0</offset>
        > <count xsi:type="xsd:int">10</count>
        > </namesp2:search>
        > </SOAP-ENV:Body>
        > </SOAP-ENV:Envelope>
        >
        > (once again, I have changed the real sessionID to $SESSIONID, for
        > privacy reasons).
        > which, while being more verbose, appears (to me) to be much the same
        > thing.
        > Unfortunately, I get this (not very useful) error message from the
        > service, after submitting the above search request:
        >
        > <faultcode>soapenv:Server.userException</faultcode>
        > <faultstring>java.lang.ArrayStoreException:
        > [Ljava.lang.Object;</faultstring>
        > <detail>
        > <ns1:hostname
        > xmlns:ns1="http://xml.apache.org/axis/">bridgaa2</ns1:hostname>
        > </detail>
        >
        > So it looks like some kind of problem with the array, but other than
        > that, I have no idea what I am doing wrong. Perhaps someone more
        > experienced with SOAP can point out my obvious mistake, or what the
        > problem may be.
        >
        > My apologies if this post has been a bit verbose with the XML, but I
        > felt it was necessary in order to figure out the problem.
        >
        >
        >
        >
        >
        >
        > Yahoo! Groups Links
        >
        >
        >
        >
        >
        >
      Your message has been successfully submitted and would be delivered to recipients shortly.