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

named function arguments

Expand Messages
  • Andrew Hicox
    Hello everyone: I m writing some services using Soap::Lite, and I need to be able to have named arguments to my subroutines. In regular perl syntax I s do
    Message 1 of 2 , Apr 11, 2005
    • 0 Attachment
      Hello everyone:

      I'm writing some services using Soap::Lite, and I need to be able to
      have named arguments to my subroutines.

      In regular perl syntax I's do something like:

      sub mySub {
      my %args = @_;
      ...
      }

      mySub (arg1 => "value1", arg2 => "value2");


      in Soap::Lite, I've discovered I can acheive this behaviour by
      enclosing the arguments in a secondary structure in the request body,
      something like:

      <SOAP-ENV:Body>
      <namesp1:mySub xmlns:namesp1="mySub">
      <myArbitraryStruct>
      <arg1 xsi:type="xsd:string">value1</arg1>
      <arg2:type="xsd:string">value2</arg2>
      </myArbitraryStruct>
      </namesp1:mySub>
      </SOAP-ENV:Body>

      doing this in a Soap::Lite client is fairly trivial, however, the
      people that'll be using my service are writing java and php clients,
      and are not to fond of <myArbitraryStuct> type situations.

      I'd much rather take the arguments inline in the body without the
      enclosing structure (delete <myArbitraryStuct> and
      </myArbitraryStruct> above).

      Is there any way for me to snag the names of the arguments inside my
      perl module without having to write my own custom deserializer?

      if I've got to write a deserializer, are there any *good* tutorials
      out there you all would suggest?

      thank you,

      -Andrew
    • Jay A. Kreibich
      ... See the thread on Accessing the SOAP::Header. Basically you need to have your server classes derived from SOAP::Server::Parameters. This will provide the
      Message 2 of 2 , Apr 11, 2005
      • 0 Attachment
        On Mon, Apr 11, 2005 at 01:24:08PM -0000, Andrew Hicox scratched on the wall:
        >
        >
        > Hello everyone:
        >
        > I'm writing some services using Soap::Lite, and I need to be able to
        > have named arguments to my subroutines.

        > Is there any way for me to snag the names of the arguments inside my
        > perl module without having to write my own custom deserializer?

        See the thread on Accessing the SOAP::Header.

        Basically you need to have your server classes derived from
        SOAP::Server::Parameters. This will provide the SOAP::SOM object to
        each function call as the last argument. You can then extract the
        full SOAP::Data members for headers and parameters from this object,
        including name and type information.

        If you need to do this for every function call, I would suggest
        writing a helper function that takes a SOM object and just extracts
        all the headers, so you can do something like this:

        sub mySoapCall
        {
        my( %args ) = myHelperPkg::ExtractParaters( pop( @_ ) );
        [...]
        }


        -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.