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

Re: [soaplite] little confused

Expand Messages
  • Jason Yates
    Thanks a lot. I understand a lot better now. Probably should have read the SOAP::Lite documentation a little closer, and could have saved myself a lot of
    Message 1 of 10 , Nov 25, 2002
    • 0 Attachment
      Thanks a lot. I understand a lot better now. Probably should have read the
      SOAP::Lite documentation a little closer, and could have saved myself a lot
      of trouble.

      I have one more problem though, with the autodispatch feature. =/

      Below is the code for the server and client.

      server:
      #!/usr/bin/perl

      use SOAP::Transport::HTTP;

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

      package Temperatures;

      sub new {
      my $self = shift;
      my $class = ref($self) || $self;
      bless {_temperature => shift} => $class;
      }

      sub as_fahrenheit {
      return shift->{_temperature};
      }

      client:
      use SOAP::Lite +autodispatch =>
      uri => 'http://www.soaplite.com/Temperatures',
      proxy => 'http://127.0.0.1/cgi-bin/temp.cgi';

      my $temperatures = Temperatures->new(100);
      print $temperatures->as_fahrenheit;


      The server and client come directly from the book "SOAP: Cross Platform Web
      Service Development Using XML". The server works when using the SOAP::Lite
      call() function. But after changing the client to work with autodispatch,
      I'm getting this perl error.

      Can't locate object method "new" via package "Temperatures" (perhaps you
      forgot to load "Temperatures"?) at temp.pl line 7.

      It looks like it's not autoloading properly, but I don't see anything wrong
      with the syntax. Any ideas?

      Jason Yates

      On Sunday 24 November 2002 22:00, you wrote:
      > Hi Jason,
      >
      > I guess there are several points that have to be clarified.
      >
      > First of all, SOAP::Lite converts module names into URIs simply
      > converting '::' into '/'. From DB::mysql you'll get DB/mysql. Other
      > methods can be used in future versions (SOAP1.2 specification
      > describes mapping from language specific names into XML), but
      > compatibility will be preserved when possible.
      >
      > Second, PATH is extracted on server side and converted into package
      > name using the same rule. It is possible thought to bind ANY URL into
      > ANY package using dispatch_with() method instead of dispatch_to().
      >
      > Third, similar logic is used on the client side, however, one
      > significant difference exists. When you use non-autodispatch mode and
      > specify namespace using uri() method it is always transferred as it
      > is (without any modifications). When you use autodispatch method, the
      > PATH element of specified namespace is ignored and generated based on
      > class/object name you're using, thus allowing you to call A->foo(),
      > and B->bar() without need to call uri() method.
      >
      > In the example below:
      >
      > use SOAP::Lite
      > ...
      > uri => 'http://www.soaplite.com/Temperatures';
      > # uri => 'http://www.soaplite.com/Foo';
      > # uri => 'http://www.soaplite.com/';
      >
      > Temperatures->new()
      >
      > will all have the same result. The host element is NOT ignored and is
      > used to generate a proper name
      > ('http://www.soaplite.com/Temperatures' in this example)
      >
      > If you use A::B->foobar() then 'http://www.soaplite.com/A/B' URL will
      > be generated.
      >
      > Forth, the example you showed in your first message won't work, but
      > because of a different reason. In your new() method wou're trying to
      > return a database handler which can't be properly serialized. You may
      > need to do it little bit differently: you can either generate your
      > handler and keep it on server side storing only id in your object; or
      > you can use objects_by_reference features which does essentially the
      > same, but doesn't require any custom coding. You just need to specify
      > that any object of class Foo has to be return as reference and
      > SOAP::Lite will do the rest (it'll store the original instance,
      > provide dummy instance, bless it into the right class on server side,
      > so you can call methods as usually, and will substitute dummy
      > instance with original object when passed back on server side). See
      > OBJECTS-BY-REFERENCE section
      > (http://theoryx5.uwinnipeg.ca/CPAN/data/SOAP-Lite/SOAP/Lite.html#OBJECTS-BY
      >-REFERENCE) and examples for more details.
      >
      > Let me know if it doesn't give you enough information.
      >
      > Best wishes, Paul.
    • Paul Kulchenko
      Hi Jason, ... I don t see anything wrong with the code either and you shouldn t have this error unless you re using Perl 5.8.0 that has bug in
      Message 2 of 10 , Nov 25, 2002
      • 0 Attachment
        Hi Jason,

        > Can't locate object method "new" via package "Temperatures"
        > (perhaps you
        > forgot to load "Temperatures"?) at temp.pl line 7.
        >
        > It looks like it's not autoloading properly, but I don't see
        > anything wrong with the syntax. Any ideas?

        I don't see anything wrong with the code either and you shouldn't
        have this error unless you're using Perl 5.8.0 that has bug in
        UNIVERSAL::AUTOLOAD handling. You need to either use dispatch_from
        instead of autodispatch or insert "{package Temperatures}" somewhere
        in your code. Let me know if it's something else.

        Best wishes, Paul.

        --- Jason Yates <jaywhy2@...> wrote:
        > Thanks a lot. I understand a lot better now. Probably should have
        > read the
        > SOAP::Lite documentation a little closer, and could have saved
        > myself a lot
        > of trouble.
        >
        > I have one more problem though, with the autodispatch feature. =/
        >
        > Below is the code for the server and client.
        >
        > server:
        > #!/usr/bin/perl
        >
        > use SOAP::Transport::HTTP;
        >
        > SOAP::Transport::HTTP::CGI->dispatch_to('Temperatures')->handle;
        >
        > package Temperatures;
        >
        > sub new {
        > my $self = shift;
        > my $class = ref($self) || $self;
        > bless {_temperature => shift} => $class;
        > }
        >
        > sub as_fahrenheit {
        > return shift->{_temperature};
        > }
        >
        > client:
        > use SOAP::Lite +autodispatch =>
        > uri => 'http://www.soaplite.com/Temperatures',
        > proxy => 'http://127.0.0.1/cgi-bin/temp.cgi';
        >
        > my $temperatures = Temperatures->new(100);
        > print $temperatures->as_fahrenheit;
        >
        >
        > The server and client come directly from the book "SOAP: Cross
        > Platform Web
        > Service Development Using XML". The server works when using the
        > SOAP::Lite
        > call() function. But after changing the client to work with
        > autodispatch,
        > I'm getting this perl error.
        >
        > Can't locate object method "new" via package "Temperatures"
        > (perhaps you
        > forgot to load "Temperatures"?) at temp.pl line 7.
        >
        > It looks like it's not autoloading properly, but I don't see
        > anything wrong
        > with the syntax. Any ideas?
        >
        > Jason Yates
        >
        > On Sunday 24 November 2002 22:00, you wrote:
        > > Hi Jason,
        > >
        > > I guess there are several points that have to be clarified.
        > >
        > > First of all, SOAP::Lite converts module names into URIs simply
        > > converting '::' into '/'. From DB::mysql you'll get DB/mysql.
        > Other
        > > methods can be used in future versions (SOAP1.2 specification
        > > describes mapping from language specific names into XML), but
        > > compatibility will be preserved when possible.
        > >
        > > Second, PATH is extracted on server side and converted into
        > package
        > > name using the same rule. It is possible thought to bind ANY URL
        > into
        > > ANY package using dispatch_with() method instead of
        > dispatch_to().
        > >
        > > Third, similar logic is used on the client side, however, one
        > > significant difference exists. When you use non-autodispatch mode
        > and
        > > specify namespace using uri() method it is always transferred as
        > it
        > > is (without any modifications). When you use autodispatch method,
        > the
        > > PATH element of specified namespace is ignored and generated
        > based on
        > > class/object name you're using, thus allowing you to call
        > A->foo(),
        > > and B->bar() without need to call uri() method.
        > >
        > > In the example below:
        > >
        > > use SOAP::Lite
        > > ...
        > > uri => 'http://www.soaplite.com/Temperatures';
        > > # uri => 'http://www.soaplite.com/Foo';
        > > # uri => 'http://www.soaplite.com/';
        > >
        > > Temperatures->new()
        > >
        > > will all have the same result. The host element is NOT ignored
        > and is
        > > used to generate a proper name
        > > ('http://www.soaplite.com/Temperatures' in this example)
        > >
        > > If you use A::B->foobar() then 'http://www.soaplite.com/A/B' URL
        > will
        > > be generated.
        > >
        > > Forth, the example you showed in your first message won't work,
        > but
        > > because of a different reason. In your new() method wou're trying
        > to
        > > return a database handler which can't be properly serialized. You
        > may
        > > need to do it little bit differently: you can either generate
        > your
        > > handler and keep it on server side storing only id in your
        > object; or
        > > you can use objects_by_reference features which does essentially
        > the
        > > same, but doesn't require any custom coding. You just need to
        > specify
        > > that any object of class Foo has to be return as reference and
        > > SOAP::Lite will do the rest (it'll store the original instance,
        > > provide dummy instance, bless it into the right class on server
        > side,
        > > so you can call methods as usually, and will substitute dummy
        > > instance with original object when passed back on server side).
        > See
        > > OBJECTS-BY-REFERENCE section
        > >
        >
        (http://theoryx5.uwinnipeg.ca/CPAN/data/SOAP-Lite/SOAP/Lite.html#OBJECTS-BY
        > >-REFERENCE) and examples for more details.
        > >
        > > Let me know if it doesn't give you enough information.
        > >
        > > Best wishes, Paul.


        __________________________________________________
        Do you Yahoo!?
        Yahoo! Mail Plus � Powerful. Affordable. Sign up now.
        http://mailplus.yahoo.com
      • Jason Yates
        I m using perl 5.8. But it works perfectly fine using dispatch_from. Thanks. Jason Yates
        Message 3 of 10 , Nov 25, 2002
        • 0 Attachment
          I'm using perl 5.8. But it works perfectly fine using dispatch_from. Thanks.

          Jason Yates

          On Monday 25 November 2002 14:16, Paul Kulchenko wrote:
          > Hi Jason,
          >
          > > Can't locate object method "new" via package "Temperatures"
          > > (perhaps you
          > > forgot to load "Temperatures"?) at temp.pl line 7.
          > >
          > > It looks like it's not autoloading properly, but I don't see
          > > anything wrong with the syntax. Any ideas?
          >
          > I don't see anything wrong with the code either and you shouldn't
          > have this error unless you're using Perl 5.8.0 that has bug in
          > UNIVERSAL::AUTOLOAD handling. You need to either use dispatch_from
          > instead of autodispatch or insert "{package Temperatures}" somewhere
          > in your code. Let me know if it's something else.
          >
          > Best wishes, Paul.
          >
          > --- Jason Yates <jaywhy2@...> wrote:
          > > Thanks a lot. I understand a lot better now. Probably should have
          > > read the
          > > SOAP::Lite documentation a little closer, and could have saved
          > > myself a lot
          > > of trouble.
          > >
          > > I have one more problem though, with the autodispatch feature. =/
          > >
          > > Below is the code for the server and client.
          > >
          > > server:
          > > #!/usr/bin/perl
          > >
          > > use SOAP::Transport::HTTP;
          > >
          > > SOAP::Transport::HTTP::CGI->dispatch_to('Temperatures')->handle;
          > >
          > > package Temperatures;
          > >
          > > sub new {
          > > my $self = shift;
          > > my $class = ref($self) || $self;
          > > bless {_temperature => shift} => $class;
          > > }
          > >
          > > sub as_fahrenheit {
          > > return shift->{_temperature};
          > > }
          > >
          > > client:
          > > use SOAP::Lite +autodispatch =>
          > > uri => 'http://www.soaplite.com/Temperatures',
          > > proxy => 'http://127.0.0.1/cgi-bin/temp.cgi';
          > >
          > > my $temperatures = Temperatures->new(100);
          > > print $temperatures->as_fahrenheit;
          > >
          > >
          > > The server and client come directly from the book "SOAP: Cross
          > > Platform Web
          > > Service Development Using XML". The server works when using the
          > > SOAP::Lite
          > > call() function. But after changing the client to work with
          > > autodispatch,
          > > I'm getting this perl error.
          > >
          > > Can't locate object method "new" via package "Temperatures"
          > > (perhaps you
          > > forgot to load "Temperatures"?) at temp.pl line 7.
          > >
          > > It looks like it's not autoloading properly, but I don't see
          > > anything wrong
          > > with the syntax. Any ideas?
          > >
          > > Jason Yates
          > >
          > > On Sunday 24 November 2002 22:00, you wrote:
          > > > Hi Jason,
          > > >
          > > > I guess there are several points that have to be clarified.
          > > >
          > > > First of all, SOAP::Lite converts module names into URIs simply
          > > > converting '::' into '/'. From DB::mysql you'll get DB/mysql.
          > >
          > > Other
          > >
          > > > methods can be used in future versions (SOAP1.2 specification
          > > > describes mapping from language specific names into XML), but
          > > > compatibility will be preserved when possible.
          > > >
          > > > Second, PATH is extracted on server side and converted into
          > >
          > > package
          > >
          > > > name using the same rule. It is possible thought to bind ANY URL
          > >
          > > into
          > >
          > > > ANY package using dispatch_with() method instead of
          > >
          > > dispatch_to().
          > >
          > > > Third, similar logic is used on the client side, however, one
          > > > significant difference exists. When you use non-autodispatch mode
          > >
          > > and
          > >
          > > > specify namespace using uri() method it is always transferred as
          > >
          > > it
          > >
          > > > is (without any modifications). When you use autodispatch method,
          > >
          > > the
          > >
          > > > PATH element of specified namespace is ignored and generated
          > >
          > > based on
          > >
          > > > class/object name you're using, thus allowing you to call
          > >
          > > A->foo(),
          > >
          > > > and B->bar() without need to call uri() method.
          > > >
          > > > In the example below:
          > > >
          > > > use SOAP::Lite
          > > > ...
          > > > uri => 'http://www.soaplite.com/Temperatures';
          > > > # uri => 'http://www.soaplite.com/Foo';
          > > > # uri => 'http://www.soaplite.com/';
          > > >
          > > > Temperatures->new()
          > > >
          > > > will all have the same result. The host element is NOT ignored
          > >
          > > and is
          > >
          > > > used to generate a proper name
          > > > ('http://www.soaplite.com/Temperatures' in this example)
          > > >
          > > > If you use A::B->foobar() then 'http://www.soaplite.com/A/B' URL
          > >
          > > will
          > >
          > > > be generated.
          > > >
          > > > Forth, the example you showed in your first message won't work,
          > >
          > > but
          > >
          > > > because of a different reason. In your new() method wou're trying
          > >
          > > to
          > >
          > > > return a database handler which can't be properly serialized. You
          > >
          > > may
          > >
          > > > need to do it little bit differently: you can either generate
          > >
          > > your
          > >
          > > > handler and keep it on server side storing only id in your
          > >
          > > object; or
          > >
          > > > you can use objects_by_reference features which does essentially
          > >
          > > the
          > >
          > > > same, but doesn't require any custom coding. You just need to
          > >
          > > specify
          > >
          > > > that any object of class Foo has to be return as reference and
          > > > SOAP::Lite will do the rest (it'll store the original instance,
          > > > provide dummy instance, bless it into the right class on server
          > >
          > > side,
          > >
          > > > so you can call methods as usually, and will substitute dummy
          > > > instance with original object when passed back on server side).
          > >
          > > See
          > >
          > > > OBJECTS-BY-REFERENCE section
          >
          > (http://theoryx5.uwinnipeg.ca/CPAN/data/SOAP-Lite/SOAP/Lite.html#OBJECTS-BY
          >
          > > >-REFERENCE) and examples for more details.
          > > >
          > > > Let me know if it doesn't give you enough information.
          > > >
          > > > Best wishes, Paul.
          >
          > __________________________________________________
          > Do you Yahoo!?
          > Yahoo! Mail Plus – Powerful. Affordable. Sign up now.
          > http://mailplus.yahoo.com
        • Paul Kulchenko
          Hi Jason, ... Yes, it does. dispatch_from uses AUTOLOAD for a specific package, whereas autodispatch uses UNIVERSAL::AUTOLOAD. The bug in 5.8 is in
          Message 4 of 10 , Nov 25, 2002
          • 0 Attachment
            Hi Jason,

            --- Jason Yates <jaywhy2@...> wrote:
            > I'm using perl 5.8. But it works perfectly fine using
            > dispatch_from. Thanks.
            Yes, it does. dispatch_from uses AUTOLOAD for a specific package,
            whereas autodispatch uses UNIVERSAL::AUTOLOAD. The bug in 5.8 is in
            UNIVERSAL::AUTOLOAD handling only (it loads a method, but not a
            package; you need to include "package Foo" declaration yourself to
            make it work).

            Best wishes, Paul.


            __________________________________________________
            Do you Yahoo!?
            Yahoo! Mail Plus � Powerful. Affordable. Sign up now.
            http://mailplus.yahoo.com
          Your message has been successfully submitted and would be delivered to recipients shortly.