Perl中的Web服务客户端 [英] Client of web service in Perl

查看:181
本文介绍了Perl中的Web服务客户端的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是客户端-我希望调用Web服务的方法.

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

我有一个Web服务地址(后缀.svc),并且有方法的名称,返回值和它们的参数.

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

该服务通过WCF(HTML端点)实现.我希望通过SOAP::Lite调用这些方法.我应该为URI,代理写什么,以及如何正确调用这些方法?

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. proxy到端点和
  2. 方法定义中名称空间的uri(或最新版本的ns).
  1. the proxy to the endpoint and
  2. the uri (or in the most recent version ns) to the namespace in the method definition.

最简单的方法之一就是使用WSDL URI并使用它创建SOAP::Schema对象,如下所示:

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();

并转储这两个对象.

您可以寻找

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.

为了使我的SOAP客户端体系结构正常工作,我不得不深入研究许多SOAP :: Lite转储.如果您想排除所有麻烦,就应该知道如何调试和转储Perl对象.

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

这篇关于Perl中的Web服务客户端的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆