Client of web service in Perl

*爱你&永不变心* 提交于 2019-12-01 12:24: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:


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 => [ ... ]
            ...
        }
    }
};


来源:https://stackoverflow.com/questions/5586145/client-of-web-service-in-perl

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