Data Infrastructure Management Software Discussions

perl webservices client

Has anybody written any code to use perl to connect to WFA webservices?  Can it be done?  The only example provided in the webservices guide uses a MS-specific auth method.  I'm trying to write some perl, but I'm stuck at the auth piece.  I'm a bit of a webservices newbie here.


Re: perl webservices client

I have done this with PHP but I assume that it will be very similar.  The key is to look at the function in the WSDL to determine what values need to be passed and how. 

<code php>

$soapClient   = new SoapClient("http://wfaServer/wfa-ws/WorkflowService_doc?wsdl",




$client->executeWorkflow (array ("workflowId" => WorkflowNumber, "userInputsEqualsValues" =>

        array ("userInput1=Value1", "userInput2=Value2")



</code php>

Re: perl webservices client

pwl Netapp Alumni

Re: perl webservices client


here is a sample code.


#!perl -w

use SOAP::Lite;

my $lite = SOAP::Lite -> service('http://wfa_ip_address/wfa-ws/WorkflowService_doc?wsdl');

print "After creating Service \n";

my $res = $lite->getAllWorkflows();

print "After calling getAllworkflows\n";

sub SOAP::Transport::HTTP::Client::get_basic_credentials {

    return 'username' => 'password';



Re: perl webservices client

None of the examples here work for me.   The PHP example I get:

PHP Parse error:  syntax error, unexpected T_VARIABLE in /root/wfa/wfa.php on line 20

And the Perl Example the variable is empty even though the script completes without error.

Re: perl webservices client

I'm having some success using the SOAP::WSDL module.

1a.  Install SOAP::WSDL and SOAP::Lite from cpan. 

1b. Libexpat-dev is required on the system first!!

2. -b /usr/lib/perl5/ http://wfaserver/wfa-ws/WorkflowService_doc?wsdl

where: /usr/lib/perl is somewhere in your @INC path and the second arg is the url of the doc/literal service for your WFA inst.

3.  Here's what I've got so far.  Replace $user and $password.  Authentication works fine, though I'd prefer to use the WSDL module auth.  The result comes back as the body of the SOAP message.  I'm now working on parsing it.  If anybody has any input on that, please speak up. 


use SOAP::Lite;
#use SOAP::Lite +autodispatch, +trace => debug;
use MyInterfaces::WorkflowService::WorkflowService_docPort;
use MyTypes::getAllWorkflows;
use MyElements::getAllWorkflows;
use MyTypemaps::WorkflowService;
use SOAP::WSDL::Client;
use SOAP::WSDL::Transport::HTTP;

my $user = "myuser";
my $password = "mypassword";

sub SOAP::Transport::HTTP::Client::get_basic_credentials {
return $user => $password ;

## Connect to service
my $service = MyInterfaces::WorkflowService::WorkflowService_docPort->new();

## Print results
#my $result = MyTypes::getAllWorkflows;
my $result = $service->getAllWorkflows();
die $result if not $result;
my $xml = $result;
print "\nMy xml:\n $xml \n\n";

Re: perl webservices client

I'm trying this sample code to call getAllWorkflows, and I have XML output enabled to help me debug this  I get the following error when using the _doc service address:

<env:Envelope xmlns:env=''><env:Header></env:Header><env:Body><env:Fault xmlns:env=''><faultcode>env:Server</faultcode><faultstring>Request struct cannot be null</faultstring></env:Fault></env:Body></env:Envelope>

I've also tried the _rpc service address, and then I get the following error:

<env:Envelope xmlns:env=''><env:Header></env:Header><env:Body><env:Fault xmlns:env=''><faultcode>env:VersionMismatch</faultcode><faultstring>Invalid SOAP envelope namespace:</faultstring></env:Fault></env:Body></env:Envelope>

I do believe that my authentication is working, as I get a different error if I put in the wrong URL or wrong user/pass.  My code is below....any thoughts?  Thanks!

#!/usr/bin/perl -w

use strict;

use SOAP::Lite;

my $user    = "admin";

my $pass    = "admin";

my $soapurl = "http://WFA_IP/wfa-ws/WorkflowService_doc?wsdl";

my $usexml  = 1;

sub SOAP::Transport::HTTP::Client::get_basic_credentials {

        return $user => $pass;


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


my $result = $service->getAllWorkflows();

print "R:$result\n";

Re: perl webservices client


use SOAP::Lite +autodispatch;


use SOAP::Lite +autodispatch, +trace => debug;

See my post elsewhere in the thread.  I'm having better success using the SOAP::WSDL module.  I believe the WFA team is working on some official documentation on WFA/perf webservice integration, so stay tuned.

Re: perl webservices client

OK, I finally got this figured out by looking at the XML request being sent by the perl script that was not working with a PHP script that was working.  The Perl script was not properly setting the namespace, so I modified the way that the Perl script connects as shown below.  Below is also an example of parsing the output sent back for the GetAllWorkflows call.  Note that I also had to use the _rpc interface instead of the _doc interface to the WFA web services.  Hope this helps someone else looking to connect to WFA web services via Perl.

#!/usr/bin/perl -w

use strict;

use SOAP::Lite;

my $user      = "admin";

my $pass      = "admin";

my $namespace = '';

my $soapurl   = 'http://WFA_IP/wfa-ws/WorkflowService_rpc?wsdl';

sub SOAP::Transport::HTTP::Client::get_basic_credentials {

        return $user => $pass;


my $service = new SOAP::Lite

        uri   => $namespace,

        proxy => $soapurl,


my $som    = $service->getAllWorkflows();

my $result = $som->result;

my $items  = $result->{'item'};

for my $item (@$items) {

        print "Workflow ID:          $item->{'id'}\n";

        print "Workflow Category:    $item->{'category'}\n";

        print "Workflow Name:        $item->{'name'}\n";

        print "Workflow Description: $item->{'description'}\n";

        print "Workflow Input: \n";

        my $inputs = $item->{'userInput'};

        for my $input (sort @$inputs) {

                print "  $input->{'name'} ($input->{'type'})\n";


        print "\n";


Re: perl webservices client

pwl Netapp Alumni

Great work mike!