Client of web service in Perl

2019-02-20 20:59发布

I am the client - I wish to call methods of a web service.

I have a web service address (.svc suffix) and I have the method's name, return value and their argument.

The service is implemented with WCF (HTML end point). I wish to call those methods by SOAP::Lite. What should I write for the URI, proxy and how exactly do I call the methods?

1条回答
淡お忘
2楼-- · 2019-02-20 21:30

You set

  1. the proxy to the endpoint and
  2. the uri (or in the most recent version ns) to the namespace in the method definition.

One of the easiest ways to do this is simply to use the WSDL URI and create a SOAP::Schema object with it, like so:

my $schema = SOAP::Schema->new( schema_url => $destination_URL )->parse();
my $services = $schema->services();

And dump those two objects.

You can look for

my $method_def = $service->{ $method_name };

my $uri   = $method_def->{namespace};
my $proxy = $method_def->{endpoint}->value();

And use those values, if everything is there.

I had to dig through a lot of SOAP::Lite dumps in order to get my SOAP client architecture working. You should know how to debug and dump Perl objects if you want to shoot all your troubles.

I'll show you an anonymized dump of a service:

$services = {
    ServiceName => {
        MethodName => {
            endpoint => bless( {
                _attr => {},
                _name => 'location',
                _signature => [],
                _value => [
                    # v-- This value you pass to SOAP::Lite->proxy
                    'http://some.domain.com/WebServices/SOAPEndpoint.asmx' 
                ]
            }, 'SOAP::Custom::XML::Data' 
            ),
            # v-- This value you pass to uri/default_ns/ns
            namespace => 'http://some.domain.com/',
            parameters => [ ... ]
            ...
        }
    }
};
查看更多
登录 后发表回答