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

Perl and Java & Arrays

Expand Messages
  • a.rutgers@yournews.net
    Hi there, I m Quite new to SOAP, searched for Java & Perl but did not find enough to solve this one: I m trying to communicate array s from Perl5 to Java via
    Message 1 of 2 , May 8, 2001
      Hi there,

      I'm Quite new to SOAP, searched for Java & Perl but did not find
      enough to solve this one:

      I'm trying to communicate array's from Perl5 to Java via SOAP::Lite.
      I figure I have to tell SOAP::Lite and/or Apache somewhere how to
      marshall the Perl array result to Java - if this is even possible.

      PS: Stuff with simple Strings works ok. The experiment with the
      lists resulted in the effect that only the last string from the
      list is returned to Java.

      Thx!

      My perl script does:

      use strict;

      use SOAP::Transport::HTTP;

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

      package SimpleClass;

      sub simple {

      print STDERR "Simple Call is called!\n";
      #my $result = "A simple string";
      #my $result = ("A less simple", "next string", "as an array" );
      my $result = ["A less simple", "next string", "as an array" ];
      return $result;
      }

      My java client does:

      import java.net.*;
      import java.util.*;
      import org.apache.soap.util.xml.*;
      import org.apache.soap.*;
      import org.apache.soap.rpc.*;

      class simple {

      public static void main(String args[]) throws Exception {
      URL url= new URL
      ("http://defcon2.development.yournews.nl:8083/pl/simple");
      String urn = "urn:SimpleClass";
      Call call = new Call ();
      call.setTargetObjectURI( urn );
      call.setMethodName ("simple");
      call.setEncodingStyleURI(Constants.NS_URI_SOAP_ENC);
      Response resp;
      resp = call.invoke (/* router URL */ url, /* actionURI
      */ "" );
      Parameter result = resp.getReturnValue ();
      Object arr = result.getValue();
      System.out.println("Parameter type:" + result.getType());
      System.out.println("Result as a string is:" + result);
      System.out.println("Object.toString = " + arr.toString());
      System.out.println("Object = " + arr);
      }
      }

      The result of jre simple is:

      Parameter type:class [Ljava.lang.String;
      Result as a string is:[name=SOAP-ENC:Array] [type=class
      [Ljava.lang.String;] [value=[Ljava.lang.String;@f4430da]
      [encodingStyleURI=null]
      Object.toString = [Ljava.lang.String;@f4430da
      Object = [Ljava.lang.String;@f4430da
    • Paul Kulchenko
      Hi, All! SOAP Cookbook is available on http://cookbook.soaplite.com/ . Thanks to Tony Hong for his great help. Not all information is available yet (20 out of
      Message 2 of 2 , May 15, 2001
        Hi, All!

        SOAP Cookbook is available on http://cookbook.soaplite.com/ .
        Thanks to Tony Hong for his great help.

        Not all information is available yet (20 out of 40 questions), more
        will be added later this week. Comments, ideas, updates or support
        will be greatly appreciated.

        Best wishes, Paul.

        P.S. For those who didn't get answer from me, I'll answer ALL
        received emails in a couple of days.

        __________________________________________________
        Do You Yahoo!?
        Yahoo! Auctions - buy the things you want at great prices
        http://auctions.yahoo.com/
      Your message has been successfully submitted and would be delivered to recipients shortly.