A Lazy Sequence

ANN: necessary-evil 2.0.0

Version 2.0.0 of necessary-evil, the Clojure library for clients and servers of one of the least loved web protocols, XML-RPC, has been released and is now available on Clojars and Github. The library is built on top of Ring and clj-html.

The following is a simple hello world server using jetty, ring and necessary-evil:

(require '[necessary-evil.core :as xml-rpc]
         '[ring.adapter.jetty :refer [run-jetty]])

(def handler (xml-rpc/end-point 
    {:hello (fn hello 
        ([] (hello "World"))
        ([name] (str "Hello, " name "!")))}))

(run-jetty handler {:port 3000 :join? false})

Thanks to everyone who has reported issues and provided feedback.

Changes

For those unfortunate enough to have needed to use necessary-evil, the following changes have occurred since version 1.2.2:

  • Updated to work with Clojure 1.2.1 and up (1.4.0 is the new default) and new contrib modules.
    • Class name munging of '-' characters in Record names caused problems using prior necessary-evil 1.x to have import errors on Clojure 1.2.1 and 1.3.
  • Changed mappings in the ValueTypeElem protocol:
    • Instead of clojure.lang.PersistanceVector, any clojure.lang.Sequential implementor will be serialized to an array; this includes lists and lazy sequences.
    • Longs are now serialized as Integers (and must not exceed Integer.MAX_VALUE as the xmlrpc spec only allows for 4 byte signed ints).
    • java.util.Date objects are now serialized to dateTime.iso8601.
  • call* function added to necessary-evil.core to add more fine grained control to the http request. call now uses call* under the hood. The major difference is that call* takes the remote functions arguments as a sequence, and has keyword options for the configurable things.
  • String values no longer normalize whitespace: You may now find you have to remove newlines or other whitespace yourself.
  • Type hints to avoid reflection added across all namespaces.

Note that the serialization and deserialization processes are now asymmetric: For example in a round trip a list will return as vector, Java dates will return as Joda time dates and longs as ints.

For the full list of changes, see the project README.

See also:

6 December 2012