Client of web service in Perl

只愿长相守 提交于 2019-12-01 14:15:15

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 => [ ... ]
            ...
        }
    }
};
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!