bubles_88 has asked for the wisdom of the Perl Monks concerning the following question:


Hi all,

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:
<readmore title ="See the code"> $resp = $svc->call(SOAP::Data->name('Hello') ->attr ({'xmlns'=>'sth'}) => SOAP::Data->name('')->value("Jimmy"));


But this results in extra tags
<Hello xmlns="sth"><c-gensym3>Jimmy</c-gensym3></Hello>
which again resulted in empty final result:
<?xml version="1.0" encoding="UTF-8"?><SOAP-ENV:Envelope xmlns:xsi=htt +p://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-EN +V:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><SOAP-ENV +:Body><Hello xmlns="sth"><c-gensym3>Jimmy</c-gensym3></Hello></SOAP-E +NV:Body></SOAP-ENV:Envelope>
[download]


What i would like to have is:
<Hello xmlns="sth">Jimmy</Hello>
<?xml version="1.0" encoding="UTF-8"?><SOAP-ENV:Envelope xmlns:xsi=htt +p://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-EN +V:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><SOAP-ENV +:Body><Hello xmlns="sth">Jimmy</Hello></SOAP-ENV:Body></SOAP-ENV:Enve +lope>
[download]


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

Could you please help me in solving this issue?

Thank you very much

Replies are listed 'Best First'.
Re: Perl Web Service
by starX (Chaplain) on Jun 10, 2008 at 14:47 UTC
    How about a regex? Something like this:
    $resp =~ s/<\/*c-gensym3>//gxms
    NB that this is very much untested, though.
Re: Perl Web Service
by Anonymous Monk on Jun 11, 2008 at 07:02 UTC
      Hi. Thanks for the response.
      I am not sure where can i modify the xml code as it is resulted from error message.
      I have also tried to go to the website.
      If I use the "/", it will add another nested element.
      What I want is:

      EXPECTED OUTPUT:
      <?xml version="1.0" encoding="UTF-8"?><SOAP-ENV:Envelope xmlns:xsi="ht +tp://www.w3.org/1999/XMLSchema-instance" xmlns:SOAP-ENC="http://schem +as.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap +.org/soap/envelope/" xmlns:xsd="http://www.w3.org/1999/XMLSchema" SOA +P-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><SOAP +-ENV:Body><Test xmlns="http://test.test.test">TEXT_APPEAR</Test></SOA +P-ENV:Body></SOAP-ENV:Envelope> SOAP::Transport::HTTP::Client::send_receive: HTTP/1.1 200 OK Server: Jetty(6.1.6) Content-Length: 206 Content-Type: text/xml Client-Date: Wed, 11 Jun 2008 10:21:18 GMT Client-Peer: 127.0.0.1:7650 SOAPAction: ""

      My Perl Code (version 1):
      use SOAP::Lite + trace => 'debug'; my $svc; my $resp; eval { $svc= SOAP::Lite ->service("http://localhost:8000/"); $resp = $svc->Test('TEXT_APPEAR'); }; die "Got Error: $@" if($@);

      OUTPUT:
      <?xml version="1.0" encoding="UTF-8"?><SOAP-ENV:Envelope xmlns:xsi="ht +tp://www.w3.org/1999/XMLSchema-instance" xmlns:SOAP-ENC="http://schem +as.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap +.org/soap/envelope/" xmlns:xsd="http://www.w3.org/1999/XMLSchema" SOA +P-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><SOAP +-ENV:Body><Test xmlns="http://test.test.test"><Test>TEXT_APPEAR</Test +></Test></SOAP-ENV:Body></SOAP-ENV:Envelope> SOAP::Transport::HTTP::Client::send_receive: HTTP/1.1 200 OK Server: Jetty(6.1.6) Content-Length: 206 Content-Type: text/xml Client-Date: Wed, 11 Jun 2008 10:21:18 GMT Client-Peer: 127.0.0.1:7650 SOAPAction: ""


      My Perl Code (version 2):
      use SOAP::Lite + trace => 'debug'; my $svc; my $resp; eval { $svc= SOAP::Lite ->service("http://localhost:8000") ->proxy("http://localhost); $resp = $svc->call(SOAP::Data->name('Test') ->attr ({'xmlns'=>'http://sth.sth.sth'}) => "TEXT_APPEAR"); }; die "Got Error: $@" if($@);


      OUTPUT:
      <?xml version="1.0" encoding="UTF-8"?><SOAP-ENV:Envelope xmlns:xsi="ht +tp://www.w3.org/1999/XMLSchema-instance" xmlns:SOAP-ENC="http://schem +as.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap +.org/soap/envelope/" xmlns:xsd="http://www.w3.org/1999/XMLSchema" SOA +P-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><SOAP +-ENV:Body><Test xmlns="http://test.test.test"><c-gensym3 xsi:type="xs +d:int">TEXT_APPEAR</c-gensym3></Greeter></SOAP-ENV:Body></SOAP-ENV:En +velope> SOAP::Transport::HTTP::Client::send_receive: HTTP/1.1 200 OK Server: Jetty(6.1.6) Content-Length: 272 Content-Type: text/xml; charset=utf-8 Client-Date: Wed, 11 Jun 2008 10:29:25 GMT Client-Peer: 127.0.0.1:7650

      Could you please help me to get the expected output?
      Thanks a lot!