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

2353Re: [soaplite] sending back a string array

Expand Messages
  • Randy J. Ray
    Feb 9, 2003
      On 2003.02.08 06:13 websocket <websocket@...> wrote:
      > I'm new to SOAP so I thought I would start with SOAP::Lite. What's
      > the syntax for sending back an array of strings. I tried something
      > like the following:
      > my @arr = ();
      > push @arr, "String 1";
      > push @arr, "String 2";
      > return @arr;
      > Note: The client will be MS .Net.

      Because of the different ways you can express arrays in XML Schema and WSDL,
      there is no one answer to this. The fact that you are writing to .Net is more
      meaningful. The client will be expecting that you adhere to the styles of WSDL
      (in fact, the client will probably expect you to provide a WSDL description
      for your service).

      This isn't an easy answer, and probably not a good thing for someone just
      starting out. First off, you are probably best off by writing the library as a
      non-web-service library, then write a wrapper lib for it that does the
      management of conversions. This makes it easier to use your core library in
      non-.Net environments. Second, rather than a list you should return a list
      reference. Your array is a single parameter, from the viewpoint of the web
      service. Because of Perl's relaxed treatment of scalars, lists, and argument
      lists, the array could be interpreted as two separate return values.

      Once you are returning a list ref, the real fun begins. You should in fact be
      returning a blessed reference, because .Net services expect everything to be
      objects and classes. The good thing is, it makes the next step easier, because
      the reference is easily-identified as a specific class of object. The next
      consideration is that the default way SOAP::Lite encodes array references
      isn't going to be what you want. You'll need to write a serialization routine,
      and use the map_type method to associate it with your class.

      Sound like an unusual amount of work? Many people who have written clients
      against MS .Net services will agree with you wholeheartedly.

      Randy J. Ray Campbell, CA http://www.rjray.org rjray@...

      Silicon Valley Scale Modelers: http://www.svsm.org
    • Show all 2 messages in this topic