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

Dispatch to a class with a different name

Expand Messages
  • thomas.lochmatter
    In all SOAP::Lite examples I ve seen, the class name was derived from the URL, e.g. When calling print SOAP::Lite -
    Message 1 of 2 , Jul 1, 2007
    • 0 Attachment
      In all SOAP::Lite examples I've seen, the class name was derived from the URL, e.g. When
      calling
      print SOAP::Lite
      -> proxy('http://services.soaplite.com/hibye.cgi')
      -> uri('http://www.soaplite.com/Demo')
      -> hi()
      -> result;
      the method hi() of the class "Demo" is invoked.

      Is there a way to configure SOAP::Lite to dispatch such requests to another class? E.g.
      $server->dispatch_to({'Demo' => 'SomeClass'});
      or even better
      $server->dispatch_to({'Demo' => $someInitializedObjectOfMyClass});
      or at least
      $server->dispatch_to({'Demo' => 'MyNamespace::Demo'});

      I'm having this problem in a project with several hundred classes where each part of the
      project lives in its own namespace. Hence all SOAP classes are supposed to be in some
      "ProjectNameAndVersion::SOAP::*" namespace.

      Thanks,
      Thomas
    • Garz
      ... from the URL, e.g. When ... another class? E.g. ... Have you looked into the dispatch_with method ? Here is a sample of my code : $server- dispatch_with ({
      Message 2 of 2 , Jul 1, 2007
      • 0 Attachment
        --- In soaplite@yahoogroups.com, "thomas.lochmatter"
        <thomas.lochmatter@...> wrote:
        >
        > In all SOAP::Lite examples I've seen, the class name was derived
        from the URL, e.g. When
        > calling
        > print SOAP::Lite
        > -> proxy('http://services.soaplite.com/hibye.cgi')
        > -> uri('http://www.soaplite.com/Demo')
        > -> hi()
        > -> result;
        > the method hi() of the class "Demo" is invoked.
        >
        > Is there a way to configure SOAP::Lite to dispatch such requests to
        another class? E.g.
        > $server->dispatch_to({'Demo' => 'SomeClass'});
        > or even better
        > $server->dispatch_to({'Demo' => $someInitializedObjectOfMyClass});
        > or at least
        > $server->dispatch_to({'Demo' => 'MyNamespace::Demo'});
        >

        Have you looked into the dispatch_with method ? Here is a sample of my
        code :


        $server->dispatch_with
        ({ $MyClass::NS => new MyClass($cgi) ,
        $MyOtherClass::NS => new MyOtherClass($cgi),
        ....
        })->handle();

        $MyClass::NS is a URL defining the SOAPAction header (at least its
        beginning). It looks like "http://server/MyClass/1.0". I use the
        version number as a way to support several versions of the API in the
        future...
        I've defined one Namespace for each of my classes, and
        have only one cgi to handle them all.

        So my SOAP client just needs to be called with ->uri($MyClass::NS) for
        the calls to be dispatched to the correct class.

        Hope this helps...
      Your message has been successfully submitted and would be delivered to recipients shortly.