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

Passing parameters between SOAP::Lite and MS .NET

Expand Messages
  • Erica Amemiya
    Hi, I ve been successfully using SOAP::Lite to pass parameters to and from other SOAP::Lite systems for some time. I started having a problem with parameters
    Message 1 of 3 , Apr 29, 2004
    • 0 Attachment
      Hi,

      I've been successfully using SOAP::Lite to pass parameters to and from
      other SOAP::Lite systems for some time.

      I started having a problem with parameters when I began communicating with
      MS .NET systems, so I started comparing the XML.

      Up to this point, I've made a call like:

      my $result = $soap->foo(CustomerID=>1, ProductID=>2, CategoryID=>3);

      which produces the following XML:

      <?xml version="1.0" encoding="UTF-8"?>
      <SOAP-ENV:Envelope
      xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
      SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
      xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
      xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance"
      xmlns:xsd="http://www.w3.org/1999/XMLSchema"
      >
      <SOAP-ENV:Body
      >
      <namesp1:foo xmlns:namesp1="server"
      >
      <c-gensym3 xsi:type="xsd:string"
      >CustomerID</c-gensym3>
      <c-gensym5 xsi:type="xsd:int"
      >1</c-gensym5>
      <c-gensym7 xsi:type="xsd:string"
      >ProductID</c-gensym7>
      <c-gensym9 xsi:type="xsd:int"
      >2</c-gensym9>
      <c-gensym11 xsi:type="xsd:string"
      >CategoryID</c-gensym11>
      <c-gensym13 xsi:type="xsd:int"
      >3</c-gensym13></namesp1:foo></SOAP-ENV:Body></SOAP-ENV:Envelope>

      The passed parameters are easily retrievable on the server using:

      sub foo {
      my($self, %args) = @_;
      ...

      I've noticed that MS .NET sends and expects to receive parameters in a
      different format. I can simulate this by making a call like:

      my $result = $soap->foo(SOAP::Data->name("CustomerID")->value(1),
      SOAP::Data->name("ProductID")->value(2),
      SOAP::Data->name("CategoryID")->value(3));

      which produces the following XML:

      <?xml version="1.0" encoding="UTF-8"?>
      <Envelope xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
      SOAP-ENV:en
      codingStyle="http://schemas.xmlsoap.org/soap/encoding/"
      xmlns:SOAP-ENV="http://s
      chemas.xmlsoap.org/soap/envelope/"
      xmlns:xsi="http://www.w3.org/1999/XMLSchema-i
      nstance" xmlns:xsd="http://www.w3.org/1999/XMLSchema"
      >
      <Body
      >
      <namesp1:foo xmlns:namesp1="http://rpc.mailonly.com/server"
      >
      <CustomerID xsi:type="xsd:int"
      >1</CustomerID>
      <ProductID xsi:type="xsd:int"
      >2</ProductID>
      <CategoryID xsi:type="xsd:int"
      >3</CategoryID></namesp1:foo></Body></Envelope>

      The main problem I'm having at the moment is that I can't figure out how to
      retrieve the parameters when an MS client connects to my mod_perl
      SOAP::Lite server.

      Any help would be greatly appreciated.

      Thanks,

      Erica
    • Erica Amemiya
      Hi, I think I figured out a solution to my problem. It s not as elegant as I would have liked, but I understand why it has to be that way. I ll post sample
      Message 2 of 3 , Apr 29, 2004
      • 0 Attachment
        Hi,

        I think I figured out a solution to my problem. It's not as elegant as I
        would have liked, but I understand why it has to be that way.

        I'll post sample code tomorrow.

        Erica

        At 08:02 PM 4/29/04, Erica Amemiya wrote:
        >(snip)
      • Erica Amemiya
        Hi, Here s how I m extracting named parameters from a MS .NET client. It should work just as well with a SOAP::Lite client sending a hash. package server; use
        Message 3 of 3 , Apr 30, 2004
        • 0 Attachment
          Hi,

          Here's how I'm extracting named parameters from a MS .NET client. It
          should work just as well with a SOAP::Lite client sending a hash.

          package server;
          use strict;
          use vars qw(@ISA);
          @ISA = qw(SOAP::Server::Parameters);

          sub getparams {
          my (@p) = @_;
          my %p;
          if(ref(my $e = $p[scalar(@p)-1]) eq "SOAP::SOM") {
          my $n = $e->method();
          %p = %$n;
          } else {
          %p = (@p);
          }
          return(%p);
          }

          sub foo {
          my $self = shift;
          my %p = getparams(@_);
          my @p;

          foreach(keys(%p)) {
          push(@p, SOAP::Data->name($_)->value($p{$_}));
          }
          return(
          @p,
          SOAP::Data->name("arg1")->value("hello"),
          SOAP::Data->name("arg2")->value("from"),
          SOAP::Data->name("arg3")->value("foo"),
          );
          }

          Erica


          At 02:14 AM 4/30/04, Erica Amemiya wrote:
          >Hi,
          >
          >I think I figured out a solution to my problem. It's not as elegant as I
          >would have liked, but I understand why it has to be that way.
          >
          >I'll post sample code tomorrow.
          >
          >Erica
          >
          >At 08:02 PM 4/29/04, Erica Amemiya wrote:
          >>(snip)
        Your message has been successfully submitted and would be delivered to recipients shortly.