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

accessing headers while using autodispatch?

Expand Messages
  • Ashley Clark
    I have two questions: 1. I can t seem to find out how to set a header in the response packet, how does that work? 2. After receiving a response using
    Message 1 of 4 , Apr 14 11:46 AM
    • 0 Attachment
      I have two questions:

      1. I can't seem to find out how to set a header in the response
      packet, how does that work?
      2. After receiving a response using autodispatch how can I get at
      the header? For example, I have the following code:

      $auth = Plumbing::Auth->new(name(email => $email),
      name(password => $pass));

      I've tried $auth->valueof('//authInfo') but obviously that works
      on the Plumbing::Auth class not SOAP::SOM. Is there another way?
      Or will I have to use the object interface, and if that is the
      case, how would my snippet above translate over?

      So, I guess it's more like 2.5 questions but I hope someone can help
      me.

      --
      chalk slayer
    • Paul Kulchenko
      Hi, Ashley! ... return 1, SOAP::Header- name(a = 1)- uri( http://my.namespace ), 2; will return 1,2 as the result AND specified header as header. Position is
      Message 2 of 4 , Apr 14 12:18 PM
      • 0 Attachment
        Hi, Ashley!

        --- Ashley Clark <aclark@...> wrote:
        > 1. I can't seem to find out how to set a header in the response
        > packet, how does that work?

        return 1, SOAP::Header->name(a => 1)->uri('http://my.namespace'), 2;

        will return 1,2 as the result AND specified header as header.
        Position is irrelevant. SOAP::Header has EXACTLY the same methods as
        SOAP::Data. uri is RECOMMENDED, because header must be namespace
        qualified.

        > 2. After receiving a response using autodispatch how can I get
        > at
        > the header? For example, I have the following code:
        >
        > $auth = Plumbing::Auth->new(name(email => $email),
        > name(password => $pass));
        >
        > I've tried $auth->valueof('//authInfo') but obviously that
        > works
        > on the Plumbing::Auth class not SOAP::SOM. Is there another
        > way?
        > Or will I have to use the object interface, and if that is
        > the
        > case, how would my snippet above translate over?

        First, SOAP::Lite->self will return OBJECT that is used for
        autodispatch and $soap->call will return SOAP::SOM object for the
        last call.

        so, in your case:

        $authinfo = SOAP::Lite->self->call->valueof('//authInfo');
        # or ->dataof(...) if you need to have access to attributes

        As for OO interface, you may call

        my $soap = SOAP::Lite->uri('http://something/Plumbing/Auth')
        ->proxy(...);
        $response = $soap->call(new => name(email => $email),
        name(password => $pass));
        $result = $response->result;
        $authInfo = $response->valueof('//authInfo');

        Basically OO calls can do the same as autodispatched calls, only you
        need to specify object first:

        AD:
        $result = CLASS->method(@parameters);

        OO:
        # specify uri as http://something/CLASS
        $result = $soap->call('method', @parameters)->result;

        AD:
        $result = $OBJECT->method(@parameters);

        OO:
        $result = $soap->call('method', $OBJECT, @parameters)->result;

        so, as usual in OO calls, it's translated to function call with
        object as the first parameter. ONLY difference is with CLASS, call,
        because CLASS name wil NOT go as the first parameter (should be
        specified in URI).

        Hope it helps.

        Best wishes, Paul.

        __________________________________________________
        Do You Yahoo!?
        Get email at your own domain with Yahoo! Mail.
        http://personal.mail.yahoo.com/
      • Ashley Clark
        * Paul Kulchenko in Re: accessing headers while using autodispatch? ... One more question then, should this uri be a real address? [long *excellent*
        Message 3 of 4 , Apr 14 12:33 PM
        • 0 Attachment
          * Paul Kulchenko in "Re: accessing headers while using autodispatch?"
          * dated 2001/04/14 12:18 wrote:

          > --- Ashley Clark <aclark@...> wrote:
          > > 1. I can't seem to find out how to set a header in the response
          > > packet, how does that work?
          >
          > return 1, SOAP::Header->name(a => 1)->uri('http://my.namespace'), 2;
          >
          > will return 1,2 as the result AND specified header as header.
          > Position is irrelevant. SOAP::Header has EXACTLY the same methods as
          > SOAP::Data. uri is RECOMMENDED, because header must be namespace
          > qualified.

          One more question then, should this uri be a real address?

          [long *excellent* explanation of OO vs AD syntax snipped]

          Thanks very much, both for the quick response and the useful answer.
          That gets me past my stumbling block here. And also, thank you very
          much for providing such a wonderful library.

          --
          really hacks
        • Paul Kulchenko
          Hi, Ashley! ... No, there is no such requirement, but ideally namespace name should be unique, so usually it s represented by company address (which is unique)
          Message 4 of 4 , Apr 14 2:38 PM
          • 0 Attachment
            Hi, Ashley!

            --- Ashley Clark <aclark@...> wrote:
            > One more question then, should this uri be a real address?
            No, there is no such requirement, but ideally namespace name should
            be unique, so usually it's represented by company address (which is
            unique) and path that describes particular project/application/task
            (which is unique inside the company). It effectively creates globally
            unique identifier. For examples, I'm using
            http://www.soaplite.com/something_specific. It doesn't need to be
            http, it could be something else and doesn't need to be resolved
            somewhere. Check XML Namespaces FAQ:
            http://www.rpbourret.com/xml/NamespacesFAQ.htm, excellent resource.

            > That gets me past my stumbling block here. And also, thank you very
            > much for providing such a wonderful library.
            Glad you like it. Next version should also provide some interesting
            features. Look for announce soon.

            Best wishes, Paul.


            __________________________________________________
            Do You Yahoo!?
            Get email at your own domain with Yahoo! Mail.
            http://personal.mail.yahoo.com/
          Your message has been successfully submitted and would be delivered to recipients shortly.