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

I bought the Perl Webservices book. I am about half way through the book and it hasn't really answers the most important question, IMHO. Why should I be excited to learn about webservices? What can I do with it? Why is SOAP better than using a webserver and LWP or some other alternative?

Replies are listed 'Best First'.
•Re: Perl Webservices...whats it good for?
by merlyn (Sage) on Mar 26, 2003 at 20:23 UTC
    Well, essentially, most SOAP transfer is merely an HTTP request, but "the devil is in the details", in terms of how the server listens for the structure of the requests and formats the data in the response. If all you want to return is a simple integer, no big deal. If you want to return a multidimensional table, you'll have to figure out how to format the data so that the rows and columns are properly delimited (and don't forget to escape and unescape the delimiters in the actual data!).

    SOAP defines common ways to serialize the data, in such a way that it can be implemented in many languages. Also, SOAP can be proxied using other technologies (SOAP over email for example). I wrote an article for apple.com about using SOAP to bridge between Perl and AppleScript, passing structured data (a hash in Perl became a record in AppleScript... transparently). That was cool, and effortless.

    SOAP is just glue. But a good glue, and multi-vendor supported. It's great that Perl has good support as well.

    -- Randal L. Schwartz, Perl hacker
    Be sure to read my standard disclaimer if this is a reply.

Re: Perl Webservices...whats it good for?
by pg (Canon) on Mar 26, 2003 at 21:21 UTC
    Why is web service good?

    Why should we reuse our code? Why should we organize our code in modules? Why should we have the OO concept? All those questions sound different, but there is a single golden thread chaining all of them. The mind set behind them is consistent.

    We want to spend less effort to achieve more of our goals, more functionality … In order to do that, we have to analyze and realize all the commonalities behind this wonderful IT world, extracting and well packaging all common solutions, for the greatest possible level of reuse.

    We started with reuse of code, now when Internet become more and more tightly connected to our business and daily life, people started to think and modulize the services they put on internet, people started to share services, resources, effort, cost …

    This is a trend, and an ongoing trend, but there is one old single golden thread behind it.

Re: Perl Webservices...whats it good for?
by dze27 (Pilgrim) on Mar 26, 2003 at 21:35 UTC

    You don't *have* to be excited by web services, but it seems cool because it's a useful standard that abstracts away a lot of messy details that it would be easier not knowing. You can easily create an application with functions, that people running different platforms and programming in different languages can call over the web. As long as their environment supports SOAP, you can communicate, never mind all the details of encoding the data, standardizing data types, error handling, etc.

    If I understand your question, SOAP isn't meant to replace using a webserver and LWP. LWP is basically a programmatic web browser. SOAP is a way of creating a web service, i.e. application that is available through the web.

    Personally I haven't written a web service yet, but I've used a couple and it was very easy to do.

Re: Perl Webservices...whats it good for?
by simon.proctor (Vicar) on Mar 27, 2003 at 00:21 UTC
    Whether you think that writing a service is for you or not (let alone in Perl). It is true that more and more is being exposed as a service. Certainly in Java and .NET (primarily C#).

    To me, that would be reason enough. Services are in the current buzzword top ten and knowing how to interface is not only good for your CV its good for keeping Perl in your programming shop (personal experience attests to this). Speaking from my personal experience, I have had programmers want to interface to my code or have their data exposed correctly and using services has been the key. Sure its a bit bloated and is really just XML over HTTP but its standardised and platform independant.

    Two strong arguments IMHO.
Re: Perl Webservices...whats it good for?
by gildir (Pilgrim) on Mar 27, 2003 at 08:43 UTC
    Fellow monk,

    I think that similar question asks the majority of IT industry. For some people the answer is obvious, for some not. It's the same with every new technology ....

    But the question you ask looks weird to me: "Why is SOAP better than using a webserver and LWP or some other alternative?" Web services (SOAP is just one building block of these) are in its essence something very different from web server. Web server's purpose to live is to serve HTTP objects (mostly HTML pages). On the other hand, web services are communication means between two computer systems. For example, SOAP messages can be transported by SMTP or plain TCP, not just HTTP.

    You should look at web services as an alternative to RPC, CORBA or Messaging Oriented Middleware, not as an alternative to Web Server. It is like to consider SMTP e-mail to be alternative to TCP/IP.

    These technologies are on different IT architecture layers.

Re: Perl Webservices...whats it good for?
by RatArsed (Monk) on Mar 27, 2003 at 11:28 UTC
    the Perl Webservices book? Anyway:

    Think of SOAP (and webservices) as a method for doing RPC over exisiting protocols such as HTTP using platform independent data (i.e. embed everything as XML)

    This changes the question to be "why would I want RPC?" -- Which is all down to the problems you're trying to solve. To pick a problem at 'random'; Let's say you want to find events near a UK postcode -- you may not want to try and collect this data locally, and might want to pull data off an existing website like local.angle - they offer a webservice that allows you to get a list of events based on your postcode with their permission -- you could just pull the data off their website, but you do have some morals, right?

    For the data providers (in the case of web services that merely retrieve data) it's a lot more efficient to give the raw data, instead of the data dispersed through the virtually manditory 30kb of navigational fluff that is merely presentational.

    Now, expand this to the cases where you want them to do something with your request (like order some books) and it becomes even more of a saving, as you're not having to "fake" form filling, etc.

    Other examples I've seen (and used) are the ability to query the Amazon catalogue, find out about DSL and cable modem availability in the UK and getting exchange rate data.

    At then end of the day, it's up to you to decide whether web services will solve your problems, and whether you'd like to reuse the services out there.

    --
    RatArsed

      "the Perl Webservices book?"

      Pretty much. "Programming Web Services with Perl" is, to my knowledge, the only dedicated web services and Perl book. There are others where Perl is covered with other languages, and there's also a couple of .NET ones, but PWSwP (details here) is THE book =)

      This is, of course, assuming the fellow's talking about that book.

        Just checking that we weren't referring to O'Reilly's "Web Services Essentials" or "Programming Web Services with SOAP"; Both which cover Web services in Perl to a greater or lesser extent...

        --
        RatArsed

Re: Perl Webservices...whats it good for?
by lucylane (Acolyte) on Mar 30, 2003 at 01:01 UTC
    It depends, it can be useful but many people rush into Web Services because it's the new thing and they really shouldn't. Martin Fowler offers excellent advice in his SD Magazine article this month, http://www.sdmagazine.com/documents/s=7897/sdm0304a/sdm0304a.htm.

    From the article which is very good advice indeed:

    If both sides of the wire use the same binary 
    mechanism, an XML interface doesn’t buy you much other 
    than a jazzier set of acronyms. If you have two systems 
    built with the same platform, you’re better off using the 
    remote call mechanism built into that platform. Web 
    services become handy when you want different platforms to 
    talk to each other. My attitude is to use XML Web services 
    only when a more direct approach isn’t possible. 
    

    BTW, are you reading the Randy Ray book? How is it?

      lucylane:
      "BTW, are you reading the Randy Ray book? How is it?"

      Yes, I got Programming Web Services with Perl By Randy J. Ray, Pavel Kulchenko. I usually really enjoy ORA books, but I think this book has alot of fluff and they didn't really get me excited about the possibilities.