Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

SOAP, WSDL, XML service/client

by agentorange (Sexton)
on Sep 09, 2013 at 16:22 UTC ( [id://1053034]=perlquestion: print w/replies, xml ) Need Help??

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

A few months ago I dabbled with SOAP and was ok calling a service and getting data from it. Trouble is not touched Perl since but I'd like to write a prototype to further my knowledge though am not entirely clear where to start.

I'd like to write a service that listens on a port with no need for a separate web server (ie. Apache). It would receive XML in a specific format and then act upon that data. I also need a client to test it.

Reading up it seems like I need:

  • SOAP::Lite for the server and client
  • WSDL service on the server
  • XML::LibXML to parse the XML
  • But I'm not entirely sure how this all hangs together and the more I google the more confused I become. This would seem a very straight forward a task but every example I've seen seems more complex and/or relies on Apache and inserting the Perl as CGI.

    Does anyone have a sample bit of code that view? ie. Basic server to receive two tags in an XML file over a port? Tend to find I need examples to get me that initial leg up!

    Any help would be greatly appreciated.

    Replies are listed 'Best First'.
    Re: SOAP, WSDL, XML service/client
    by jhourcle (Prior) on Sep 09, 2013 at 16:49 UTC

      You don't need XML::LibXML, as SOAP::Lite does the unpacking for you.

      As for the WSDL, if you're only going to be calling this from SOAP::Lite, and will never need to use another language to access it, you can probably ignore that part, too. (SOAP::Lite will handle *most* things correctly when serializing, but if you have a string that looks like a number, it could flag it as an integer, and then strictly typed languages get really, really upset).

      For the sample code, take a look at the SOAP::Lite cookbook. It covers all of your questions. (the webserver-less version is SOAP::Transport::HTTP::Daemon)

        Thank you.

        Looks like I can make use of "dispatch_to(..)" to process the XML as well.

        http://cookbook.soaplite.com/#writing%20a%20server

        I will need WSDL though. I've a project spinning up and I can see that a web service for a tiny part of it will be really useful and I know the other guys will be querying it with something other than Perl. Probably Java.

          Creating a WSDL ater the fact, especially if you have complex structures (hashes of arrays of hashes of hashes) gets really, really messy. I'd highly recommend reading Which style of WSDL should I use? and Re: Starting on SOAP before you even start.

          As you're using a WSDL file, you can drop the typing of each and every variable, and go with RPC/literal or doc/lit wrapped. (RPC/encoded, which is SOAP::Lite's default is useful if you don't have a firm specification, and the clients are flexible enough to deal with changes, but it causes no end of headaches with C and Java clients if something gets typed wrong)

          There are also some absolutely awful SOAP services out there -- the strangest one that I have to deal with, the programmers obviously didn't understand SOAP, because they return a single value (an XML encoded string, that has multiple values encoded in it).

    Re: SOAP, WSDL, XML service/client
    by Anonymous Monk on Sep 09, 2013 at 21:22 UTC

    Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Domain Nodelet?
    Node Status?
    node history
    Node Type: perlquestion [id://1053034]
    Front-paged by Arunbear
    help
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this?Last hourOther CB clients
    Other Users?
    Others meditating upon the Monastery: (3)
    As of 2024-04-23 23:40 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      No recent polls found