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

Different object returned by using SOAP::Lite->proxy() or SOAP::Lite->service() ?

Expand Messages
  • Cristina Aurrecoechea
    I would like to understand the following but I cant find good tutorials on this. It seems the returned object ($service in client below) is different if I use
    Message 1 of 3 , Apr 18, 2005
    • 0 Attachment
      I would like to understand the following but I cant
      find good tutorials on this.

      It seems the returned object ($service in client
      below) is different if I use SOAP::Lite->service(wsdl)
      or if I use SOAP::Lite->proxy(servicelocation)

      When using SOAP::Lite->proxy(), and then calling the
      method (getNameList which returns a string[4]), I
      obtain something that prints as 1 and cannot be
      dereferenced. In order to obtain the reference to the
      array, I need to use the valueof() statement below.

      When using SOAP::Lite->service(), and then calling the
      method , I obtain right away the reference to the
      array. Then I just need to dereference it and print
      the items.
      (in this case the valueof() statement needs to be out,
      or you get an error, "cannot execute valueof() to an
      unblessed reference")

      Can someone explain this behavior or give me some
      pointer to an explanation?

      One more question: in my example, the uri() is
      useless. The program works without it or even if I use
      it with a non-existing namespace. Probably this is
      because the information given in proxy() is enough to
      find the service. When is uri() necessary and should
      its value correspond to the targetNamespace in WSDL
      file?

      Thanks
      Cristina

      -----------------------------------------------------------------------------------------------------------------------------------------------
      $service = SOAP::Lite

      -> uri('http://aurrecotest')

      ->proxy('http://mango.ctegd.uga.edu:9021/axis/services/TestArrayService')
      #
      ->service("http://mango.ctegd.uga.edu/webservicestest/TestArrayService.wsdl")
      ;


      #without, 1999 schemas are used and server acts out
      $service->serializer->namespaces({"http://schemas.xmlsoap.org/soap/encoding/"=>"SOAP-ENC","http://schemas.xmlsoap.org/soap/envelope/"=>"SOAP-INV","http://www.w3.org/2001/XMLSchema"=>"xsd","http://www.w3.org/2001/XMLSchema-instance"=>"xsi"});

      $result = $service->getNameList();
      $result =
      $result->valueof('//getNameListResponse/getNameListReturn');

      while (@$result){
      $item = shift @$result;
      print "$item\n";
      }
    • Graham Irvine
      ... I never noticed that .. I always use proxy though so thats probably why. Looks like using service will return the xml already packaged up to the
      Message 2 of 3 , Apr 18, 2005
      • 0 Attachment
        --- In soaplite@yahoogroups.com, Cristina Aurrecoechea <aurreco@y...>
        wrote:
        > I would like to understand the following but I cant
        > find good tutorials on this.
        >
        > It seems the returned object ($service in client
        > below) is different if I use SOAP::Lite->service(wsdl)
        > or if I use SOAP::Lite->proxy(servicelocation)
        >
        > When using SOAP::Lite->proxy(), and then calling the
        > method (getNameList which returns a string[4]), I
        > obtain something that prints as 1 and cannot be
        > dereferenced. In order to obtain the reference to the
        > array, I need to use the valueof() statement below.
        >
        > When using SOAP::Lite->service(), and then calling the
        > method , I obtain right away the reference to the
        > array. Then I just need to dereference it and print
        > the items.
        > (in this case the valueof() statement needs to be out,
        > or you get an error, "cannot execute valueof() to an
        > unblessed reference")
        >
        > Can someone explain this behavior or give me some
        > pointer to an explanation?

        I never noticed that .. I always use proxy though so thats probably
        why. Looks like using service will return the xml already
        packaged up to the //getNameListResponse/getNameListReturn path.
        Im a bit bemused as to how , surely the server is doing this
        I guess we need to know if that is repeatable across the board
        or a "bug" in the server you are connecting too ..

        and if the former ..

        Maybe Byrne/Paul can tell us if thats a feature or not <G>.

        I guess it should return the same structure and if this was ms soap
        toolkit then it would and it would be the ONLY structure you could
        get. Personally If it turns out to be soap::lite i like the fact you
        can get it packaged both ways and would vote for this as a feature and
        very much in the perl tradition to boot.

        In the meantime , its a workable solution to use one or the other.

        > One more question: in my example, the uri() is
        > useless. The program works without it or even if I use

        I think Byrne has already intimated that uri is going to be
        depreciated in favour of the more common understanding of it
        as a registered namespace. ( see announcement on www.soaplite.com
        homepage ) .

        > it with a non-existing namespace. Probably this is
        > because the information given in proxy() is enough to
        > find the service. When is uri() necessary and should
        > its value correspond to the targetNamespace in WSDL
        > file?

        yes it should . And if you can , define it . If the server ignores it
        then that doesnt matter ..

        Its almost always necessary with .NET server , albeit as
        an attribute to the method request. But also to construct
        the SOAPAction header.

        SOAPAction is another of those things that has never been pinned down
        in the soap schema and i read they were thinking to get rid of it (in
        1.2 ) , or did they decide to tighten it up . bah .. no wonder we have
        some much interop mess :D

        However in practice it is sometimes required , sometimes not .. Again
        depends on server . One server solution ive come across , who shall
        remain nameless , absolutely demand it but then dont care what the
        hell you put in it .. mmm :)

        Graham


        > Thanks
        > Cristina
        >
        >
        -----------------------------------------------------------------------------------------------------------------------------------------------
        > $service = SOAP::Lite
        >
        > -> uri('http://aurrecotest')
        >
        >
        ->proxy('http://mango.ctegd.uga.edu:9021/axis/services/TestArrayService')
        > #
        >
        ->service("http://mango.ctegd.uga.edu/webservicestest/TestArrayService.wsdl")
        > ;
        >
        >
        > #without, 1999 schemas are used and server acts out
        >
        $service->serializer->namespaces({"http://schemas.xmlsoap.org/soap/encoding/"=>"SOAP-ENC","http://schemas.xmlsoap.org/soap/envelope/"=>"SOAP-INV","http://www.w3.org/2001/XMLSchema"=>"xsd","http://www.w3.org/2001/XMLSchema-instance"=>"xsi"});
        >
        > $result = $service->getNameList();
        > $result =
        > $result->valueof('//getNameListResponse/getNameListReturn');
        >
        > while (@$result){
        > $item = shift @$result;
        > print "$item\n";
        > }
      • Byrne Reese
        This is fixed in the lastest development version of SOAP::Lite. SOAP- service returns the actual result - usually a SCALAR. :-/ Not ideal for most people.
        Message 3 of 3 , Apr 19, 2005
        • 0 Attachment
          This is fixed in the lastest development version of SOAP::Lite.
          SOAP->service returns the actual result - usually a SCALAR. :-/ Not
          ideal for most people.

          SOAP->proxy returns a SOAP::SOM object.

          In SOAP::Lite 0.65_4 I believe, one can ask for the SOAP::SOM object
          from a SOAP->service() call, by setting the preference:

          SOAP->want_som(1);

          As for the second question - yes, uri is perhaps a bad choice of names
          (it is being deprecated and renamed in SOAP::Lite 0.65_5). It specifies
          the namespace.

          Byrne

          Cristina Aurrecoechea wrote:

          > I would like to understand the following but I cant
          > find good tutorials on this.
          >
          > It seems the returned object ($service in client
          > below) is different if I use SOAP::Lite->service(wsdl)
          > or if I use SOAP::Lite->proxy(servicelocation)
          >
          > When using SOAP::Lite->proxy(), and then calling the
          > method (getNameList which returns a string[4]), I
          > obtain something that prints as 1 and cannot be
          > dereferenced. In order to obtain the reference to the
          > array, I need to use the valueof() statement below.
          >
          > When using SOAP::Lite->service(), and then calling the
          > method , I obtain right away the reference to the
          > array. Then I just need to dereference it and print
          > the items.
          > (in this case the valueof() statement needs to be out,
          > or you get an error, "cannot execute valueof() to an
          > unblessed reference")
          >
          > Can someone explain this behavior or give me some
          > pointer to an explanation?
          >
          > One more question: in my example, the uri() is
          > useless. The program works without it or even if I use
          > it with a non-existing namespace. Probably this is
          > because the information given in proxy() is enough to
          > find the service. When is uri() necessary and should
          > its value correspond to the targetNamespace in WSDL
          > file?
          >
          > Thanks
          > Cristina
          >
          > -----------------------------------------------------------------------------------------------------------------------------------------------
          > $service = SOAP::Lite
          >
          > -> uri('http://aurrecotest') <http://aurrecotest%27%29>
          >
          > ->proxy('http://mango.ctegd.uga.edu:9021/axis/services/TestArrayService')
          > <http://mango.ctegd.uga.edu:9021/axis/services/TestArrayService%27%29>
          > #
          > ->service("http://mango.ctegd.uga.edu/webservicestest/TestArrayService.wsdl")
          > ;
          >
          >
          > #without, 1999 schemas are used and server acts out
          > $service->serializer->namespaces({"http://schemas.xmlsoap.org/soap/encoding/"=>"SOAP-ENC","http://schemas.xmlsoap.org/soap/envelope/"=>"SOAP-INV","http://www.w3.org/2001/XMLSchema"=>"xsd","http://www.w3.org/2001/XMLSchema-instance"=>"xsi"});
          >
          > $result = $service->getNameList();
          > $result =
          > $result->valueof('//getNameListResponse/getNameListReturn');
          >
          > while (@$result){
          > $item = shift @$result;
          > print "$item\n";
          > }
          >
          >
          >
          > ------------------------------------------------------------------------
          > *Yahoo! Groups Links*
          >
          > * To visit your group on the web, go to:
          > http://groups.yahoo.com/group/soaplite/
          >
          > * To unsubscribe from this group, send an email to:
          > soaplite-unsubscribe@yahoogroups.com
          > <mailto:soaplite-unsubscribe@yahoogroups.com?subject=Unsubscribe>
          >
          > * Your use of Yahoo! Groups is subject to the Yahoo! Terms of
          > Service <http://docs.yahoo.com/info/terms/>.
          >
          >
        Your message has been successfully submitted and would be delivered to recipients shortly.