Web Service

A Web Service is a service that is hosted inside a webserver and which communicates by messages encoded within some higher protocol (usually HTTP). The two major classes of web service are the SOAP-based services and the RESTful services; they have substantially different theories behind them.

SOAP

SOAP services communicate by messages, which approximate to service calls. The messages are usually conveyed as the XML body of an HTTP POST (or its response) and consist of an envelope that contains a header part and a body part. The header is used to convey meta-information such as message routing info or security tokens. The body holds the “content” of the message, or can be a fault (i.e., an exception/error). SOAP messages can be conveyed by other mechanisms (e.g., SMTP or XMPP) though these are relatively rare by comparison with HTTP.

SOAP services are typically described in WSDL, a comprehensive and heavyweight language with support for many optional features and enormous depth of complexity.

The most popular package for SOAP in Tcl is TclWS, available at http://core.tcl.tk/tclws/

REST

REpresentational State Transfer, REST services are tightly coupled to HTTP, and are characterized by conceiving of the service as a collection of resources that can have simple operations applied to them (the HTTP verbs, such as GET, POST, PUT, and DELETE). Resources refer to each other by URLs; RESTful clients are not supposed to synthesize their own URLs at all. Some operations are performed by using HTTP content negotiation to arrange for different representations of the resources to be transferred. It's common for REST applications to support XML for the content type of their messages as it has tremendous richness of inline metadata, but other types (notably JSON) are also frequently used.

Some REST services are described in WADL , but they are generally expected to be at least partially self-describing. Theoretically they can be described by WSDL, but this is rare in practice.

tcllib includes a REST package

Discussion

CL notes that "Web Service" (WS) is an exceptionally confusing and misleading label, which he explains here: [L1 ]. In the meantime, ...

See http://www.oreillynet.com/lpt/a//webservices/2002/02/12/webservicefaqs.html . for info on web services.

LV: Wow - it's three years later, and now web services are really beginning to make an impact. More info would really be useful. Anyone have a gentle introduction?

Bryan Oakley notes: the above article states 'The easiest way to get started with Web services is to learn XML-RPC'. An even easier way is to download Gerald Lester's Web Services for Tcl and follow the examples. In maybe 15-20 minutes you can create a web service and a client to connect to that web service. It doesn't get much easier than that. (admittedly, the above article was written in 2002 so they can hardly be blamed for the oversight :-)

GWL: see also WebServices for Tcl: http://code.google.com/p/tclws/ , and http://www.tclscripting.com/articles/nov06/article1.html for an example of using the library to call the Google SOAP Search API.

LV: Is there a new location for the tclscripting article? It appears that someone has taken over that site...

George Petasis The project has been moved to: http://core.tcl.tk/tclws/home

LV: Gerald, if one is wanting to interact with someone's existing web service - say Google, etc. will your client be sufficient?

GWL: Yes, in general.

LV: What kind of information does one need to have to write an application that interacts with a web service?

GWL: You need the WSDL and Tcl 8.5 and definition of what the web service methods do/want.


See also

  • http://c2.com/cgi/wiki?WebServices .
  • Article on programming web services in a scripting language [L2 ]
  • SOAP
  • WSDL
  • WebServices
  • Leela is an XOTcl-based Web Service infrastructure for loosely-coupled business services. Each peer is controlled in one or more federations. Within this environment peers can collaborate in a simple-to-use, loosely coupled, and ad hoc style of communication.