Perl's SOAP::Lite can deserialize beans.

Example:

A very simple bean class:

// Temperature.java
package test;

public class Temperature {
  private double temp;

  public Temperature() {
    temp = 0d;
  }

  public double getTemperature() {
    return temp;
  }

  public void setTemperature(double temp) {
    this.temp = temp;
  }
}
  
And a class containing a method to return an instance:

// TempServer.java
package test;

public class TempServer {
  public Temperature getTemp() {
        return new Temperature();
  }
}

Deployed as "urn:Temp".

Perl client:

# demo.pl
use SOAP::Lite;
use Data::Dumper;

# Connect to the service
my $soap = SOAP::Lite
     -> uri('urn:Temp')
     -> proxy('http://myserver.com/soap/servlet/rpcrouter');

# Call the method
my $result = $soap->getTemp();

# Check for error
unless ($result->fault) {
    # Fetch the JavaBean data
    my $object = $result->result();
    # Print the data contained in it
    print $$object{temperature}, "\n";
    print Dumper($object);
} else {
    die $result->faultstring;
}

If you use Data::Dumper to look at the $object you can see that it is an
instance of test.Temperature, and it's a hash (all objects in Perl are)
mapping the instance variable to a value. The output is:

0.0
$VAR1 = bless( {
                 'temperature' => '0.0'
               }, 'test.Temperature' );


So, really a trivial demo.



Reply via email to