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

Re: [soaplite] how will I set attributes in method element using ->service ?

Expand Messages
  • Paul Kulchenko
    Hi Angelos, ... It s not possible to do using the available interface, however if you really need to do this, something like this might work for you: use
    Message 1 of 2 , Dec 8, 2002
    • 0 Attachment
      Hi Angelos,

      --- a_moschovinos <angelos@...> wrote:
      > I need to use the ->service mechanism to connect to a SOAP server.
      > How can I set an attribute in the method element ?
      It's not possible to do using the available interface, however if you
      really need to do this, something like this might work for you:

      use SOAP::Lite;

      my $service = SOAP::Lite
      ->
      service('http://services.xmethods.net/soap/urn:xmethods-delayed-quotes.wsdl');

      my $attrs = {foo => 'bar'}; # attributes to add
      my $oldname = ref $service; # current package name
      my $newname = 'Foo'; # new package name
      eval qq! # create new call() method that will add attributes
      package $newname; \@${newname}::ISA='$oldname';
      sub call {
      my \$self = shift;

      \$self->SUPER::call(SOAP::Data->name(shift)->uri(\$self->uri)->attr(\$attrs
      || {}), \@_);
      }
      1;
      ! or die;
      bless $service => $newname; # rebless

      print $service->getQuote('MSFT'), "\n";

      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.