[cl-soap-devel] Re: cl-soap - the first 15 minutes of playing with it

Sven Van Caekenberghe scaekenberghe at common-lisp.net
Wed Oct 5 14:18:30 UTC 2005


Hi Kristian,

On 05 Oct 2005, at 00:48, Kristian Elof Sørensen wrote:

> Hi
>
> I just downloaded your cl-soap program and had a go. Here are the
> problems I encountered during the first minutes of playing with it.
>
>     Kristian
>
> ------------------------------------------------
>
> All code is on cmucl 19b on Linux on x86
>
> CL-SOAP> (lisp-implementation-version)
> "19b (19B)"
> CL-SOAP> (lisp-implementation-type)
> "CMU Common Lisp"

Thanks for taking the time to check out the CL-SOAP code!

> ;; OK - just to prove that the software is installed and works
> CL-SOAP> (describe-wsdl-soap (parse-wsdl-url
> "http://www.xmethods.net/sd/2001/CurrencyExchangeService.wsdl"))
> WSDL Document Definitions named CurrencyExchangeService
>   Service: CurrencyExchangeService
>     Port: CurrencyExchangePort
>     SOAP Address Location "http://services.xmethods.net:80/soap"
>     Binding: tns:CurrencyExchangeBinding SOAP style [rpc]
>       Operation: getRate
>         Input: getRateRequest
>           Part: country2 of type: xsd:string
>           Part: country1 of type: xsd:string
>         Output: getRateResponse
>           Part: Result of type: xsd:float
>
> ;; Interesting error message when the cause is that the elof.dk server
> returns a 404 error, see below
> CL-SOAP> (describe-wsdl-soap (parse-wsdl-url
> "http://elof.dk/does.not.exist.wsdl"))
> XML parser found <hr> not matched by </hr> but by <body> near stream
> position 308.
>    [Condition of type S-XML:XML-PARSER-ERROR]
>
> Restarts:
>   0: [ABORT] Abort handling SLIME request.
>   1: [ABORT] Return to Top-Level.
>
> Backtrace:
>   0: (S-XML::PARSE-XML-ELEMENT #<String-Input Stream>
> #<S-XML:XML-PARSER-STATE {59B8A8B5}>)
>   1: (S-XML::PARSE-XML-ELEMENT #<String-Input Stream>
> #<S-XML:XML-PARSER-STATE {59B8A8B5}>)
>   2: (S-XML::PARSE-XML-ELEMENT #<String-Input Stream>
> #<S-XML:XML-PARSER-STATE {59B8A8B5}>)
>   3: (S-XML::PARSE-XML-ELEMENT 2 #<String-Input Stream>
> #<S-XML:XML-PARSER-STATE {59B8A8B5}>)[:EXTERNAL]
>   4: (S-XML:START-PARSE-XML #<String-Input Stream>
> #<S-XML:XML-PARSER-STATE {59B8A8B5}>)
>   5: ((METHOD S-XML:PARSE-XML-DOM NIL (T #)) #<#1=unused-arg> #<#1#>
> #<String-Input Stream> #<#1#>)
>   6: (PARSE-WSDL #<String-Input Stream>)
>   7: (PARSE-WSDL-URL "http://elof.dk/does.not.exist.wsdl")
>   8: (EVAL (DESCRIBE-WSDL-SOAP (PARSE-WSDL-URL
> "http://elof.dk/does.not.exist.wsdl")))
>  --more--
>
> # tail -n 1 access_log
> www.elof.dk 10.10.10.4 - - [05/Oct/2005:00:20:38 +0200]
> "GET /does.not.exist.wsdl HTTP/1.1" 404 317 "-" "HTTP Client CMU  
> Common
> Lisp 19b (19B)"

I added an optional test that enforces the response code for do-http- 
get on the url passed to parse-wsdl-url and parse-xsd-url to be 200.  
Incidentally, if the error was presented in proper XHTML, the XML  
parse would have succeeded, but it would report missing a  
<definitions> tags...

> #|
>  On the webpage http://common-lisp.net/project/cl-soap/
>  The line
>  (asd:oos 'asdf:load-op :cl-soap)
>  is missing an #\f in asdf at the start.
>  People are bound to copy and paste the line like I did ,-)
> |#

Thanks for noticing and reporting this typo.

> ;;  The first example from your webpage
> (defun xmethods-get-quote (symbol)
>   "Calling
> http://services.xmethods.net/soap/urn:xmethods-delayed-quotes.wsdl"
>   (let ((ns "urn:xmethods-delayed-quotes"))
>     (s-xml:register-namespace ns "ns1" :ns1)
>     (let* ((xmethods (make-soap-end-point
> "http://64.124.140.30:9090/soap"))
>            (result (soap-call xmethods
>                               '()
>                               `((ns1::|getQuote|
>                                  soapenv:|encodingStyle| ,
> +soap-enc-ns-uri+
>                                  :|xmlns:ns1| ,ns)
>                                 ((:|symbol| xsi::|type| "xsd:string")
>                                  ,symbol))
>                               :soap-action
> "urn:xmethods-delayed-quotes#getQuote")))
>       (if (eql (lxml-get-tag result) 'ns1::|getQuoteResponse|)
>           (let ((contents (lxml-find-tag :|Result| (rest result))))
>             (if contents
>                 (coerce (read-from-string (lxml-get-contents  
> contents))
> 'float)
>               (error "Expected a <Result> element")))
>         (error "Expected a <getQuoteResponse> element")))))
>
> Reader error at 403 on #<String-Input Stream>:
> package "NS1" not found
>    [Condition of type LISP::READER-PACKAGE-ERROR]
>
> Restarts:
>   0: [ABORT] Abort handling SLIME request.
>   1: [ABORT] Return to Top-Level.
>
> Backtrace: [...]

Doing this in the LispWorks IDE gives you the option (restart) of  
actually creating the missing package.
The source code file test/test-basic.lisp where this code snippet  
came from *does* contain the (make-package :ns1) statement. I added a  
remark to the HTML page index.html noticing that the code assumes  
there exists a package named :ns1.

Sven





More information about the cl-soap-devel mailing list