[cl-soap-cvs] CVS update: cl-soap/test/test-basic.lisp
Sven Van Caekenberghe
scaekenberghe at common-lisp.net
Sat Sep 10 19:56:29 UTC 2005
Update of /project/cl-soap/cvsroot/cl-soap/test
In directory common-lisp.net:/tmp/cvs-serv29909/test
Modified Files:
test-basic.lisp
Log Message:
added the random.org example (contributed by carlos.ungil at bluewin.ch)
Date: Sat Sep 10 21:56:28 2005
Author: scaekenberghe
Index: cl-soap/test/test-basic.lisp
diff -u cl-soap/test/test-basic.lisp:1.2 cl-soap/test/test-basic.lisp:1.3
--- cl-soap/test/test-basic.lisp:1.2 Thu Sep 8 17:39:46 2005
+++ cl-soap/test/test-basic.lisp Sat Sep 10 21:56:28 2005
@@ -1,6 +1,6 @@
;;;; -*- mode: lisp -*-
;;;;
-;;;; $Id: test-basic.lisp,v 1.2 2005/09/08 15:39:46 scaekenberghe Exp $
+;;;; $Id: test-basic.lisp,v 1.3 2005/09/10 19:56:28 scaekenberghe Exp $
;;;;
;;;; Some test for the basic SOAP protocol
;;;;
@@ -76,6 +76,26 @@
(coerce (read-from-string (second contents)) 'float)
(error "Expected a <Result> element")))
(error "Expected a <getRateResponse> element")))))
+
+;; contributed by carlos.ungil at bluewin.ch
+;; http://www.random.org/soap.html
+;; http://www.random.org/RandomDotOrg.wsdl
+;; http://www.random.org/clients/soap/
+
+(defun get-random-number (&key unsigned)
+ "Returns a true random number in the interval [2^31, 2^31) or [0, 2^31)"
+ (let ((ns "urn:RandomDotOrg"))
+ (s-xml:register-namespace ns "ns1" :ns1)
+ (let* ((rng (make-soap-end-point "http://www.random.org/cgi-bin/Random.cgi"))
+ (result (soap-call rng
+ nil
+ (if unsigned
+ `((ns1::|lrand48| :|xmlns:ns1| ,ns))
+ `((ns1::|mrand48| :|xmlns:ns1| ,ns))))))
+ (if (or (eql (lxml-get-tag result) 'ns1::|lrand48Response|)
+ (eql (lxml-get-tag result) 'ns1::|mrand48Response|))
+ (values (parse-integer (second (second result))))
+ (error "Expected a <lrand48Response> or <mrand48Response> element")))))
;; accessing local AXIS services
More information about the Cl-soap-cvs
mailing list