CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Advanced:
Perl Web CLient

 



bubles_88
New User

Jun 10, 2008, 7:03 AM

Post #1 of 2 (1487 views)
Perl Web CLient Can't Post

Hi all,

I am new to Perl.. And I really really need your help. I would like to develop a Perl Web CLient consuming Web Service made in Java (apache CFX). THe Web Server produces WSDL in localhost.

I have two questions:

1. Are there ways other than SOAP that I can use to develop this Web Client?

2. I have tried using SOAP::Lite. The Web Service (WSDL) has operation called Hello which accept input(input:Hello) and output the input(output:HelloResponse). Here is my Perl code:

Expected: Input: Jimmy Output: Jimmy

$svc = SOAP::Lite
-> service('http://localhost:8000/Hello.wsdl')
-> proxy('http://localhost:8000/Hello')
-> on_action(sub {sprintf '%s/%s', @_});

$resp = $svc->Hello("Jimmy");

However, this code will produce empty result. Executing "print $resp" produces empty result.

I have tried using SOAP::Data as below:

$resp = $svc->call(SOAP::Data->name('Hello')
->attr ({'xmlns'=>'sth'})
=> SOAP::Data->name('')->value("Jimmy"));



But this results in extra tags which again resulted in empty final result:

<?xml version="1.0" encoding="UTF-8"?><SOAP-ENV:Envelope xmlns:xsi=http://www.w3.org/1999/XMLSchema-instance xmlns:SOAP-ENC=http://schemas.xmlsoap.org/soap/encoding/ xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/1999/XMLSchema" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><SOAP-ENV:Body><Hello xmlns="sth"><c-gensym3>Jimmy</c-gensym3></Hello></SOAP-ENV:Body></SOAP-ENV:Envelope>

What i would like to have is:

<?xml version="1.0" encoding="UTF-8"?><SOAP-ENV:Envelope xmlns:xsi=http://www.w3.org/1999/XMLSchema-instance xmlns:SOAP-ENC=http://schemas.xmlsoap.org/soap/encoding/ xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/1999/XMLSchema" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><SOAP-ENV:Body><Hello xmlns="sth">Jimmy</Hello></SOAP-ENV:Body></SOAP-ENV:Envelope>

Do you know how to remove the tags <c-gensym3> entirely?

Could you please help me in solving this issue?

Thank you very muchSmile


winfinit
User

Jun 18, 2008, 5:52 PM

Post #2 of 2 (1423 views)
Re: [bubles_88] Perl Web CLient [In reply to] Can't Post

couple of advices:

if you have a properly formated wsdl document then look into
SOAP::WSDL
http://search.cpan.org/~mkutter/SOAP-WSDL-2.00.04/lib/SOAP/WSDL.pm
this guy did amazing job with this module, if you dont have a properly formatted WSDL then dont use it, just look into your requirements XML, and use something like this

Code
my $soap = new SOAP::Lite; 
$soap->uri($nameSpace);
$soap->proxy($proxy); #for you this is localhost i assume
my $CommunityFindAccountsMethod = SOAP::Data->name('MethodExpected')
->attr({xmlns => $nameSpace});
my @CommunityFindAccountsValues = (
SOAP::Data->name('parameter' => 'data'),
# SOAP::Data->name('FieldName' => 'SEARCHFIELD_LOGINID'),
);
my $search = $soap->call($CommunityFindAccountsMethod => @CommunityFindAccountsValues);
#$search->valueof('//AccountList/AdminAPIBaseAccountInfo/nAccountNumber');
return $search->valueof('//AccountList/AdminAPIBaseAccountInfo/nAccountNumber');


also do "use SOAP::Lite +trace => 'all';"

that way you can see all your XML output, and you can see what you are sending in raw XML, so you can adjust your code.

let me know if you need to construct some specific XML i can help you to write it with SOAP::Lite.

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives