Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

How to use Perl instead of Coldfusion.

by flexvault (Parson)
on May 13, 2013 at 18:22 UTC ( #1033326=perlquestion: print w/ replies, xml ) Need Help??
flexvault has asked for the wisdom of the Perl Monks concerning the following question:

Dear Monks,

I'm looking for a way to code the following in Perl. I did a lot of 'super searches', but nothing enlightened me. I had expected the API to be in 'C' or 'C++', which I would have a better idea of what to do, so when I received the Coldfusion example, a language I have never had to deal with before, I knew I needed help.

<cfinvoke webservice="https://10.16.47.116/Efiling/EfilingWS?wsdl" method="getOcscData" returnvariable="result"> <cfinvokeargument name="inXML" value="<Envelope><Parameters><Method>Pe +rson</Method> <FirstName>Michael%</FirstName> <LastName>Smith%</LastN +ame> </Parameters></Envelope>"/> </cfinvoke>

Any assistance or direction would be greatly appreciated.

Thank you...Ed

"Well done is better than well said." - Benjamin Franklin

Comment on How to use Perl instead of Coldfusion.
Download Code
Re: How to use Perl instead of Coldfusion.
by space_monk (Chaplain) on May 13, 2013 at 18:33 UTC

    This looks to be some sort of XML/SOAP interface? Anyone? Bueller? :-)

    This is incredibly tentative and it is entirely possible I do not know what I'm talking about :-)

    use Data::Dumper; use SOAP::WSDL; my %data = ( 'inXML' => "<Envelope><Parameters><Method>Pe +rson</Method> <FirstName>Michael%</FirstName> <LastName>Smith%</LastN +ame> </Parameters></Envelope>" ); my $soap = SOAP::WSDL->new( wsdl => 'https://10.16.47.116/Efiling/EfilingWS?wsdl', ); my $result = $soap->call('getOcscData', %data); print Dumper( $result);
    If you spot any bugs in my solutions, it's because I've deliberately left them in as an exercise for the reader! :-)

      Hello space_monk,

      Yes, the coldfusion code is initiating a search and then up to 75 responses are received in XML format.

      Thank you

      "Well done is better than well said." - Benjamin Franklin

Re: How to use Perl instead of Coldfusion.
by InfiniteSilence (Curate) on May 13, 2013 at 18:43 UTC

    I remember responding to some user that was recently asking how to implement SOAP in Perl using a WSDL file. It would be nice to see an example that simply uses a WSDL. I don't use SOAP very much nowadays since all of the infrastructure seems like too much overhead.

    Celebrate Intellectual Diversity

      Hello InfiniteSilence ,

      When I did my 'super searches', I didn't find your example.

      The web service already exists and I need the client side (Perl) to ask the question and then accept the response. I don't have a clue what the WSDL file is and hope that it is already defined on the web server. My web service is totally independent, but I'm required to verify if the 'person' is already a client. Part of the XML response is a client ID that I need to use if they already exist in the service.

      By answering the comments, I'm starting to understand this a little more :-)

      Thank you...Ed

      "Well done is better than well said." - Benjamin Franklin

        WSDL file is...

        WSDL can be stored in a file or be the XML response to a query, so the response from your initial request (the one with WSDL in it) should return WSDL content. If your client understands WSDL it should be able to extract the service information from it and allow you to call that service based purely on the definition specified in the WSDL. Otherwise your client would have to know some things about the specific web service like which address to use, etc.

        Celebrate Intellectual Diversity

Re: How to use Perl instead of Coldfusion.
by space_monk (Chaplain) on May 13, 2013 at 20:13 UTC

    Start looking on CPAN at SOAP::WSDL and similar modules. It's not an area I've worked with recently, but I think reading the above module description may give you some clues as to how to get things going.

    If you spot any bugs in my solutions, it's because I've deliberately left them in as an exercise for the reader! :-)
Re: How to use Perl instead of Coldfusion.
by Khen1950fx (Canon) on May 13, 2013 at 21:01 UTC

    HTML::Macro incorprates some CFML. Give it a shot.

    Update: I managed to find the missing link: WDDX
Re: How to use Perl instead of Coldfusion.
by sundialsvc4 (Abbot) on May 14, 2013 at 02:49 UTC

    “Cold Fusion cfspoken cfhere.” CFDon’t cfpanic.

    ColdFusion tends to be a bit baroque in its approaches.   If you truly know absolutely nothing about the web service that you will be contacting, and/or its public interface must be regarded as malleable and your solution must be future-proof (in the eyes of some committee somewhere), then you may have little choice but to jump in with both feet and use e.g. SOAP::WSDL.   Otherwise, and I expect far more likely, simpler modules like SOAP::Lite should be more than sufficient.

    You will definitely appreciate the relative brevity of Perl’s syntax for successfully invoking a web service.   CF’s syntax is by comparison very baroque.   You can sort-of glom what call is made, what parameters are being passed-in, and where the result comes out, but cfit’s cfnot cfeasy.

    Martin Kutter’s passing comment (in SOAP::WSDL::Manual’s page) that “sometimes, WSDL definitions are incomplete,” just might qualify as the world’s biggest understatement.   Sometimes, WSDLs aren’t worth the bits they’re printed on, such that clients which rely too heavily on them (such as ColdFusion ...) can be seriously tripped-up by an “impedance mismatch” between what the service promises and what it actually does.   If you can figure a stable way to make the call that doesn’t fool around with all that extra protocol-baggage ... and you almost always can ... definitely go that route.

Re: How to use Perl instead of Coldfusion.
by Anonymous Monk on May 14, 2013 at 07:03 UTC

    SOAP::Simple, just a hair simpler than SOAP::Lite, lots of the robustness as XML::Compile -- if it works for you it works, if it doesn't , watch the XML::Compile slides

    #!/usr/bin/perl -- use Path::Class; use constant THISFILE => file( __FILE__ )->absolute->stringify; use constant THISDIR => file( THISFILE )->dir->stringify; use strict; use warnings; use SOAP::Simple; use Data::Dumper; use autodie qw/ chdir /; chdir THISFILE; #~ http://search.cpan.org/~markov/XML-Compile-1.21/lib/XML/Compile/FAQ +.pod use Log::Report mode => 'DEBUG'; use LWP::Simple qw/ mirror /; my $wsdlurl = 'https://10.16.47.116/Efiling/EfilingWS?wsdl'; my $wsdlfile = 'EfilingWS.wsdl'; -e $wsdlfile or mirror( $wsdlurl, $wsdlfile ); my $soap = SOAP::Simple->new( $wsdlfile ); my ($answer, $trace) = $soap->getOcscData( Method => 'Person', FirstName => 'Michael%', Lastname => 'Smith%', ); $trace->printRequest; print Dumper($answer),"\n"; print Dumper($trace),"\n";

    My soap tips (I hate soap), SOAP::Lite is too much work, SOAP::Simple is less work work ... its built on XML::Compile::SOAP/http://perl.overmeer.net/xml-compile/#doc , see my treasure trove of soap examples and lost knowledge,$soap->transport->add_handler("request_send", \&pp_dump );, http://cookbook.soaplite.com/

Re: How to use Perl instead of Coldfusion.
by flexvault (Parson) on May 14, 2013 at 22:05 UTC

    Dear Monks,

    Thanks to all for your input. Especially the AM with the exact solution using "SOAP::Simple".

    I'm on the latest Debian Linux and cannot get "SOAP::Simple" to install. I get that CPAN doesn't know what it is, so I downloaded the source from "CPAN", and I spent all day installing pre-reqs, and when it finally asked for me to install "Moose" (which I did), I thought maybe this is a late April fools day joke.

    I did buy the book "Perl & XML" from Amazon and did install "SOAP::Lite" without a problem on this system.

    Would any one know/show how to use "SOAP::Lite" to solve the problem? After this unsuccessful day, I hope this is the one and only time I need to work with "SOAP".

    Thank you...Ed

    "Well done is better than well said." - Benjamin Franklin

      Pretty much the same way, almost, read the cookbook

      Also all day installing ? cpanp -i BERLE/SOAP-Simple-0.00_03.tar.gz

        Dear Anonymous Monk,

        Thanks for the heads-up and I will read the cookbook. But to see if I would finally have some success, I installed using your 'cpanp' suggestion and the results are below:

        root@email# /usr/opt/perl5_32/bin/cpanp -i BERLE/SOAP-Simple-0.00_03.t +ar.gz [MSG] No '/root/.cpanplus/custom-sources' dir, skipping custom sources [MSG] No '/root/.cpanplus/custom-sources' dir, skipping custom sources [MSG] No '/root/.cpanplus/custom-sources' dir, skipping custom sources Installing SOAP::Simple (0.00_03) *** Install log written to: /root/.cpanplus/install-logs/SOAP-Simple-0.00_03-1368612787.log Module 'SOAP::Simple' installed successfully No errors installing all modules root@email# pyrperl PM_soap_example.plx Couldn't load class (SOAP::Simple::Trait) because: Can't locate XML/Co +mpile/WSDL11.pm in @INC (@INC contains: /usr/opt/perl5_32/lib/site_pe +rl/5.12.2/i686-linux /usr/opt/perl5_32/lib/site_perl/5.12.2 /usr/opt/ +perl5_32/lib/5.12.2/i686-linux /usr/opt/perl5_32/lib/5.12.2 .) at /us +r/opt/perl5_32/lib/site_perl/5.12.2/SOAP/Simple/Trait.pm line 5. BEGIN failed--compilation aborted at /usr/opt/perl5_32/lib/site_perl/5 +.12.2/SOAP/Simple/Trait.pm line 5 . Compilation failed in require at /usr/opt/perl5_32/lib/site_perl/5.12. +2/SOAP/Simple/Base.pm line 3. BEGIN failed--compilation aborted at /usr/opt/perl5_32/lib/site_perl/5 +.12.2/SOAP/Simple/Base.pm line 3. Compilation failed in require at /usr/opt/perl5_32/lib/site_perl/5.12. +2/SOAP/Simple.pm line 6. BEGIN failed--compilation aborted at /usr/opt/perl5_32/lib/site_perl/5 +.12.2/SOAP/Simple.pm line 6. Compilation failed in require at PM_soap_example.plx line 9. BEGIN failed--compilation aborted at PM_soap_example.plx line 9. root@email#

        • 'pyrperl' is a symbolic link to the Perl in directory '/usr/opt/perl5_32/bin/'.
        • line 9 is the 'use SOAP::Simple' statement.

        It was looking for 'SOAP::Simple::Trait' and 'XML/Compile/WSDL11.pm' that consumed the day. I'm not complaining, just explaining. Thanks for the help.

        Thank you...Ed

        "Well done is better than well said." - Benjamin Franklin

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1033326]
Approved by Old_Gray_Bear
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (10)
As of 2014-10-02 11:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    What is your favourite meta-syntactic variable name?














    Results (56 votes), past polls