Writing a SOAP Client using the SOAP::Lite package for Perl is very simple. This tutorial walks you through a simple client that accesses the PING service hosted at http://www.xmethods.net
The following line imports the SOAP::Lite package for use by the client.
"Proxy" is the SOAP Endpoint When this line is executed, the library encodes the method parameters by autodetecting type and assigning a system-generated name to this parameter (for basic types like "string" or "integer" , most server implementations ignore the input parameter names and just focus on the values, using parameter order as a way to map to service method arguments). If you want more control over the encoding process, you can use the following: Once the response object is created, you can check to see if a fault was returned:
Otherwise, the result is stored in $response->result:
If the response had been an array, the returned value would have been an array reference. As you can see, writing SOAP::Lite clients is very easy!
"URI" is the namespace identifier for the Interface / Object
"pingHost" is the method itself.
"www.yahoo.com" is the string argument for the pingHost method.
pingHost ( SOAP::Data->name("Hostname")->value("www.yahoo.com")->type("string") );
die "Fault: ".$response->faultcode." ".$response->faultdetail." ".$response->faultstring if $response->faultcode;
print $response->result;
In the case of this example, because the PING service responds with a string, the returned value is a string.
If the response had been a structure, the returned value would have been a hash reference.