By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,852 Members | 2,220 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,852 IT Pros & Developers. It's quick & easy.

Perl client to AXIS2 with arrays

P: 1
Hi,

I set up an Axis POJO service and perl cient using SOAP::Lite.
I am able to receive all simple types of return values (String, int, etc.) and also arrays (String[] in the POJO service).
The trouble begins when I try to pass a perl array from the client to the server.
I am not able to receieve it as String[] , only as parameters to a method, which means I need to know the size of the array I am sending which may vary.

Some code ...
Server (AXIS2 POJO):
Expand|Select|Wrap|Line Numbers
  1. package samples.myquickstart.service.pojo;
  2.  
  3. import java.util.HashMap;
  4. import java.util.Date;
  5. import java.lang.reflect.Array;
  6.  
  7. public class GetStuffService {
  8. ...
  9.     public double getDouble() {
  10.          return 100.00;
  11.     }
  12.     public int getInt() {
  13.          return 100;
  14.     }
  15.     public String getStringTest() {
  16.          return "test";
  17.     }
  18.  
  19.     public String getHello(String name) {
  20.          return "Hello,"+name;
  21.     }
  22.  
  23.     public String[] getArray () {
  24.         return string_array;
  25.     }
  26.  
  27.     // Does not work
  28.     public String[] setArray (String[] str_array) {
  29.         string_array = str_array;
  30.         return string_array;
  31.     }
  32.  
  33.     // Does not work, tried also without "toString"
  34.     public String setArray1 (Array str_array) {
  35.         //string_array1 = str_array;
  36.         //return string_array1;
  37.         return str_array.toString();
  38.     }
  39.  
  40.     // This works , but then I am limited to array of size 3
  41.     public String[] setArray2 (String str0, String str1, String str2) {
  42.         string_array[0] = str0;
  43.         string_array[1] = str1;
  44.         string_array[2] = str2;
  45.         return string_array;
  46.     }
  47.  
  48.  
  49. }
  50.  
Client (Perl with SOAP::Lite) :
Expand|Select|Wrap|Line Numbers
  1. use SOAP::Lite;
  2. use perl_axis_client;
  3.  
  4.  
  5. my $service = "GetStuffService";
  6. my $namespace = "http://myquickstart.samples/xsd";
  7. my $proxy = getAxisConnection($service,$namespace);
  8.  
  9. ...
  10. my $str = $proxy->getStringTest();  
  11. if (callSuccess($str)) {
  12.     print $str->result."\n";             
  13. }
  14.  
  15. my $int = $proxy->getInt();
  16. if (callSuccess($int)) {
  17.     print $int->result."\n";
  18. }
  19.  ...
  20. my @test_array = ("Testingx","withx","newx","xxx");
  21. my $hello = $proxy->setArray1(@test_array);
  22. if (callSuccess($hello)) {
  23.     print "Get array1:".$hello->result."\n";
  24.     @res = $hello->paramsout;
  25.     #print "Res array size:".$#res."\n";
  26.     print "Res array1:@res\n";
  27. }
  28.  
  29. @test_array = ("Testingy","withy","newy","yyy");
  30. my $hello = $proxy->setArray2(@test_array);
  31. if (callSuccess($hello)) {
  32.     print "Get array2:".$hello->result."\n";
  33.     @res = $hello->paramsout;
  34.     #print "Res array size:".$#res."\n";
  35.     print "Res array2:@res\n";
  36. }
  37.  
Thanks,
Rinat
Jan 14 '09 #1
Share this Question
Share on Google+
1 Reply


KevinADC
Expert 2.5K+
P: 4,059
To me it looks like the problem is in the java(?) code. I don't know java, so I can only suggest you ask on a Java forum how to stringify your array properly.
Jan 14 '09 #2

Post your reply

Sign in to post your reply or Sign up for a free account.