将PHP SoapClient转换为Perl SOAP :: Lite

时间:2016-09-29 22:01:59

标签: php perl soap-client soaplite five9

我正在编写一个与five9 API一起使用的Web应用程序。我有一个工作的PHP脚本,使用API​​打印出第一个用户的电子邮件。我的应用程序是在Perl中,我试图避免shelling到PHP脚本。我曾尝试使用SOAP :: Lite,但遇到了困难。这是我正在使用的PHP脚本。

#!/usr/bin/php
<?php

$soap = null;
$wsdl = "https://api.five9.com/wsadmin/v2/AdminWebService?wsdl";

$user = "johnsmith@example.com";
$pass = "password";

$soap_options = array("login" => $user, "password" => $pass, "trace" => 1);

$soap = new SoapClient($wsdl, $soap_options);

$arryParams['userNamePattern'] = '';

$result = $soap->getUsersInfo($arryParams);

if(isset($result->return)) {
    $objRecords = $result->return;
    print $objRecords[0]->generalInfo->EMail;
    print "\n";

}

?>

以下是我到目前为止使用perl和SOAP :: Lite

的内容
#!/usr/bin/env perl

use warnings;
use strict;

use MIME::Base64;
use Data::Dumper;
use SOAP::Lite +trace => [ transport => sub { print $_[0]->as_string } ];

my $wsdl_five9 = 'https://api.five9.com/wsadmin/AdminWebService?wsdl&user=johnsmith@example.com';
my $uri  = 'https://api.five9.com/wsadmin/AdminWebService';
my $user = 'johnsmith@example.com';
my $password = 'password';

my $authorize = 'Basic '.encode_base64($user . ":" . $password);

my $client = SOAP::Lite->service($wsdl_five9);

$client->on_fault(
    sub {
        my $soap = shift;
        my $res = shift;

        if(ref($res) eq '') {
            die($res);
        } else {
            die($res->faultstring);
        }
        return new SOAP::SOM;
    }
    );

print "Done\n";

如果有人有使用perl和SOAP的经验,我们将非常感谢任何见解。

0 个答案:

没有答案