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

Document SOAP as Opposed to RPC

Expand Messages
  • jgubler
    The application I am working on really calls for document-based as opposed to rpc-based SOAP. I feel as if SOAP::Lite was not really written with this approach
    Message 1 of 1 , Oct 3, 2002
    • 0 Attachment
      The application I am working on really calls for document-based as
      opposed to rpc-based SOAP. I feel as if SOAP::Lite was not really
      written with this approach in mind. Still, I like many features of
      SOAP::Lite and I am hoping that there is a way to accomplish my
      objectives without switching to another toolkit.

      Suppose I want my client to submit an XML document to a web service
      for processing. I think I have a handle on this side. I construct the
      desired XML data and then use SOAP::Data->type('xml' => $xmldata) to
      get the job done. There may be some namespace issues here to work
      out, but I think that's close.

      On the server-side, I am less certain of how to proceed. Let's say
      that I have created the following server code:

      ---
      #!/usr/bin/perl

      use SOAP::Transport::HTTP;

      SOAP::Transport::HTTP::CGI
      -> dispatch_to('Services')
      -> handle;

      package Services;

      sub MyGroceries
      {
      ...
      }
      ---

      My client can then invoke this with something like:

      ---
      #!/usr/bin/perl

      use SOAP::Lite;

      my $soap = SOAP::Lite
      -> uri('urn:myservice')
      -> proxy('http://myserver.com/SOAP/services.cgi');

      ...

      $soap->MyGroceries(SOAP::Data->type('xml' => $groceries_xml));
      ---

      The question is, what is the exact nature of the arguments that will
      be received by Services::MyGroceries() on the server side? It looks
      to me like it's getting the class name as the first argument and a
      hash reference as the second. The hash appears to contain the XML
      elements as keys, with their content as values, organized in a
      hierarchical fashion. If the XML contains anything moderately
      complicated, such as element attributes, this hash fails to reflect
      those features.

      For example, suppose the client passed the following simple XML:

      <Item>
      <Name type="simpleName">Cheerios</Name>
      </Item>

      The hash passed to Services::MyGroceries() would look something like:

      {
      'Item' => {},
      'Name' => 'Cheerios'
      }

      What happened to the attribute on the 'Name' element? This clearly
      will not do.

      My problems would be solved if I could simply access the raw SOAP
      body element from within the MyGroceries() method. At that point, I
      would just grab the whole XML document as a string and feed it into
      my favorite parser for processing. Does anyone know how to do this?

      Is there another approach I should be considering? Please don't
      recommend RPC SOAP.

      -Joe
    Your message has been successfully submitted and would be delivered to recipients shortly.