开发者

How do I access Web service methods using Perl?

I wis开发者_开发知识库h to execute two Web service methods using Perl. I have the URL of this Web service and it has a .svc extension. I also have the method names, what they receive as parameters and what they return. How can I do it? If you can be detailed, it will be good.

I tried:

use SOAP::Lite;
use SOAP::TRANSPORT;

$client = SOAP::Lite->new();
$client->SOAP::TRANSPORT::HTTP('http://perl-server/perl.svc');
print $client->method_1("hi");
print $client->result();

But it returns always 1 and I need to get the answer "true" as a result from method_1. I think it returns 1 not from this method, but due to the connection passed successfully.


Took me a while to get this too:

WSDL - web service definition (lang) page where SOAP can read a standard format of all the functions/classes available on the server and how to talk to them. Basically a header file.

URI - a class definition page, so that you can write a SOAP server class and then give it to 100s of people and everyone can point to the same definition file so when you update everyone, SOAP clients don't have to update anything

PROXY - the actual implementation of the URI class, usually written in wsdl. This is the page you actually connect and talk to.

This is why you need a Proxy and a URI to connect to a SOAP service - definition, and actual server. as for the perl code,

my $cli = SOAP::Lite->proxy('proxyurl')->uri('uriurl');

my $call_return_obj = $cli->somefunc('hello');
if ($call_return_obj->faultstring ne '')
{
   print "somethin bad happened: ".$call_return_obj->faultstring."\n";
}
else
{
   my $resultstruct = $call_return_obj->results;
}

Then it gets even more tricky. Nested types are expressed as pointers to arrays / hashes filled with more pointers of other arrays or hashes, only the last level of array/hash can have actual values in it. This is how they are returned from SOAP::Lite too.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜