• Index
  •  » Talend Open Studio for Data Integration » Usage, Operation
  •  » Getting SOAP c"omplex" array (perl)

#1 2009-08-10 16:36:38

FredT
New member
Registered: 2009-08-10
Posts: 6

Getting SOAP c"omplex" array (perl)

Tags: [linux, perl, TOS 3.1.3]

Hi,

(I'm a new Talend user, and new on the forum too - but I'm quite old in the art of trying and using new software. I plan to use Talend to test a new SOAP interface for our software. I'm using the Perl flavour on an Ubuntu client, all perl modules are installed).

I've read all related topics on "complex arrays" , and tried everything I could, but I can't manage to get data from this WSDL, http://examples.qcodo.com/examples/communication/example_service.php?wsdl , with GetPeople method & "Smith" as a parameter.

This page http://examples.qcodo.com/examples/communication/soap.php explains how this service works - and it works very well from soapUI.

I just get : "ArrayOfPerson=ARRAY(0x98d05b0)" from my tWebServiceInput_1.

I read [Forum, topic 2016] How to read from a webservice ? about this, but I couldn't find how to apply it. And http://talendforge.org/test/ws/soap_server.php?wsdl seems to have disappeared...

(I succedeed using "AddNumbers" method).

Is there a way to handle this - getting 
- Alex Smith
- Wendy Smith
-Jennifer Smith
back ?

Thanks (a lot) in advance,

Fred

Last edited by FredT (2009-08-12 00:01:44)

Offline

#2 2009-08-12 00:11:05

FredT
New member
Registered: 2009-08-10
Posts: 6

Re: Getting SOAP c"omplex" array (perl)

Well, I've spent some more hours today trying things and googling... I just can't figure how to achieve this, and I can't imagine it would be not possible.

Obviously Toni-Fatec and plegall succeeded, but some part of their explanations are missing... and the link they provided, http://talendforge.org/test/ws/soap_server.php?wsdl , is dead.

I'll read every clue with great attention...

TIA

Fred

Offline

#3 2009-08-27 14:13:01

FredT
New member
Registered: 2009-08-10
Posts: 6

Re: Getting SOAP c"omplex" array (perl)

hmmm... is there anything wrong with my questions ?

Offline

#4 2009-08-27 15:38:29

plegall
Member
Registered: 2006-09-19
Posts: 1586
Website

Re: Getting SOAP c"omplex" array (perl)

FredT wrote:

hmmm... is there anything wrong with my questions ?

Nothing wrong with your question. Here comes a solution :-)

I'm going to propose a solution a bit more complex than "just a tWebServiceInput", so I wand to explain why. The "problem" is that GetPeople is not returning an "ARRAY", but a specific "ArrayOfPerson".

Code:

$ stubmaker.pl http://examples.qcodo.com/examples/communication/example_service.php?wsdl

$ perl "-MExampleService qw(:all)" -le "use Data::Dumper; print Dumper(GetPeople('Smith'))"
$VAR1 = bless( [ 
                 bless( { 
                          '__blnRestored' => 1,
                          'FirstName' => 'Alex',
                          'Id' => '5',
                          'LastName' => 'Smith'
                        }, 'Person' ),
                 bless( { 
                          '__blnRestored' => 1,
                          'FirstName' => 'Wendy',
                          'Id' => '6',
                          'LastName' => 'Smith'
                        }, 'Person' ),
                 bless( { 
                          '__blnRestored' => 1,
                          'FirstName' => 'Jennifer',
                          'Id' => '10',
                          'LastName' => 'Smith'
                        }, 'Person' )
               ], 'ArrayOfPerson' );

And if you look at the Perl code generated by tWebServiceInput, you can see that I check for an "ARRAY", not a "ArrayOfPerson". This is something I had not expected when I designed this component (but things can changed, you'll see what I propose in the next post).

So, tWebServiceInput can't produce a nice data structure as output but only a big Perl structure, and tPerlRow will do the smart job. The code in tPerlRow is:

Code:

foreach my $person (@{ $input_row[array_of_person] }) {
    push @persons, [$person->{FirstName}, $person->{LastName}];
}

By default the tArrayIn component is not visible in the palette. You have to make it visible. Go in the "Project settings" (button in the toolbar), Designer > Palette Settings.


Uploaded Images

Offline

#5 2009-08-27 15:53:01

plegall
Member
Registered: 2006-09-19
Posts: 1586
Website

Re: Getting SOAP c"omplex" array (perl)

And now, what about improving tWebServiceInput to make things a bit simpler when the data structure returned by the webservice is called "array*".

In tWebServiceInput_begin.perljet, I've replaced:

Code:

if (ref $result_<%=cid%> eq 'ARRAY') {

by

Code:

my $ref_<%=cid%> = ref $result_<%=cid%>;

if ($ref_<%=cid%> =~ m/^ARRAY/i) {

And now... standing ovation, the job becomes much simpler. No tPerlRow anymore, no tArrayIn.


Uploaded Images

Offline

#6 2009-08-27 15:53:54

plegall
Member
Registered: 2006-09-19
Posts: 1586
Website

Re: Getting SOAP c"omplex" array (perl)

FredT, may I ask you to create a feature request in the bugtracker to ask for this improvement to be integrated into next release?

Offline

#7 2009-08-27 16:21:34

FredT
New member
Registered: 2009-08-10
Posts: 6

Re: Getting SOAP c"omplex" array (perl)

Waow, THIS is an answer big_smile !!! I'm standing on my chair to write this (...hmmm... quite dangerous !!!).

Ok, I'm going to try this now... and I'll post my success, then ask for a feature request.

Thanks a lot !

Offline

  • Index
  •  » Talend Open Studio for Data Integration » Usage, Operation
  •  » Getting SOAP c"omplex" array (perl)

Board footer

Powered by FluxBB