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

Re: Accessing SOAP::Header

Expand Messages
  • jameshargreavesgmail
    Thanks - but I still can t access the header! If I perform the following call: my $test = $soap- soapimport( SOAP::Data- name(client_id = client_id )
    Message 1 of 4 , Apr 11 5:41 AM
    • 0 Attachment
      Thanks - but I still can't access the header! If I perform the
      following call:

      my $test = $soap->soapimport( SOAP::Data->name(client_id => 'client_id')
      ->type('string'),
      SOAP::Data->name(password => 'password')
      ->type('string'),
      SOAP::Header->name(check => 'check')
      ->type('string'),
      )->result;

      and my soapimport method looks as below:

      sub soapimport
      { my $self = shift;

      die SOAP::Fault->faultcode(qw(HeaderProcessing))
      ->faultstring(Dumper(\@_));
      }

      I get returned in the faultstring:

      $VAR1 = [
      \'client_id\',
      \'password\'
      ];

      If I perform a 'pop' this simply removes the last element (password)
      from @_.

      Why am I not able to access the envelope as you suggest?

      Thanks
      Jay

      --- In soaplite@yahoogroups.com, "§hõbhãñ™" <show2sh@y...> wrote:
      > Jay,
      >
      > On the server side, SOAP headers can be accessed as follows:
      >
      > sub authenticate {
      > my $self = shift;
      > my $env = pop;
      > my $str = $env->dataof("//MessageHeader/client_id")->value
      > return SOAP::Data->name("client_id" => "$str");
      > }
      >
      > Hope this helps
      >
      > / S \
      >
      > --- jameshargreavesgmail <james.hargreaves@g...> wrote:
      > >
      > > No doubt another stupid question from yours truly ;)
      > >
      > > I have a SOAP::Transport::HTTP::CGI server and a simple SOAP::Lite
      > > client. I can send a SOAP::Header fine:
      > >
      > > ===
      > > soapimport.pl
      > > ---
      > > $soap = new SOAP::Lite
      > > -> uri($uri)
      > > -> proxy($server);
      > >
      > > $session_id = $soap->soapimport( SOAP::Header->name(client_id =>
      > > $client_id),
      > > SOAP::Header->name(password =>
      > > $password) )->result;
      > > ===
      > >
      > > but I don't know how to extract the SOAP::Header on the server so I
      > > can verify the parameters:
      > >
      > > ===
      > > soapimport.cgi
      > > ---
      > > use SOAP::Transport::HTTP;
      > >
      > > use TPG_SOAPImport;
      > >
      > > SOAP::Transport::HTTP::CGI
      > > ->dispatch_to(qw(TPG_SOAPImport))
      > > ->handle;
      > > ===
      > >
      > > ===
      > > TPG_SOAPImport.pm
      > > ---
      > > package TPG_SOAPImport;
      > >
      > > sub soapimport
      > > { my $self = shift;
      > >
      > > # verify details
      > > $self->authenticate;
      > >
      > > # do some stuff
      > > ...
      > > }
      > >
      > > sub authenticate
      > > { my $self = shift;
      > >
      > > # how do i access the SOAP::Header element here ???
      > > return undef;
      > > }
      > >
      > > 1;
      > > ===
      > >
      > > Any help would be appreciated!
      > >
      > > Thanks
      > > Jay
      > >
      > >
      > >
      > >
      >
      >
      >
      > __________________________________
      > Do you Yahoo!?
      > Yahoo! Small Business - Try our new resources site!
      > http://smallbusiness.yahoo.com/resources/
    • Jay A. Kreibich
      ... The server function soapimport needs to be part of a package that is derived (e.g., has an @ISA value) from the SOAP::Lite package
      Message 2 of 4 , Apr 11 8:02 AM
      • 0 Attachment
        On Mon, Apr 11, 2005 at 12:41:49PM -0000, jameshargreavesgmail scratched on the wall:
        >
        > Thanks - but I still can't access the header! If I perform the

        > Why am I not able to access the envelope as you suggest?

        The server function "soapimport" needs to be part of a package that
        is derived (e.g., has an @ISA value) from the SOAP::Lite package
        'SOAP::Server::Parameters'. This clues in SOAP::Lite to append the
        SOAP::SOM object as the last argument.

        Once you have a reference to the SOM object, you can extract the
        headers in to a hash with the call "headers". Example:

        ----------------------------------------------------------------------

        package mySoapPackage;
        our( @ISA ) = ( 'SOAP::Server::Parameters' );

        [...]

        sub soapimport
        {
        my( $class ) = shift( @_ );
        my( $som ) = pop( @_ );
        my( $hdr ) = $som -> header( );
        my( $ck ) = $hdr -> {'check'};

        # $ck is a scalar string value, not a SOAP::Data object

        [...]
        }

        ----------------------------------------------------------------------

        The SOM object can also be used to extract named parameters and other
        elements of the transaction.

        -j

        --
        Jay A. Kreibich | CommTech, Emrg Net Tech Svcs
        jak@... | Campus IT & Edu Svcs
        <http://www.uiuc.edu/~jak> | University of Illinois at U/C
      Your message has been successfully submitted and would be delivered to recipients shortly.