[cl-soap-devel] a couple of bug fixes

Carlos Ungil carlos.ungil at bluewin.ch
Fri Sep 9 16:50:24 UTC 2005


Hello,

I found the project looking at http://common-lisp.net/project/?M=D
I check that url from time to time to see what's going on.

Thanks for adding this extension. In fact it turns out that I can leave  
out completely the encoding stuff, my web service works fine even if I  
don't use the optional attributes.

The only problem I see is that according to the SOAP specification (if  
I understood it correctly when I took a look a few days ago) it's  
possible to have several elements in the body; I don't think such a  
message can be created using cl-soap. Not that I need that at all, but  
it might be an issue in the future.

Cheers,

Carlos

PS: I've been experimenting as well with a public web service:

;;http://www.random.org/soap.html
;;http://www.random.org/RandomDotOrg.wsdl
;;http://www.random.org/clients/soap/
(defun get-random-number (&keyword 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")))))

> Carlos,
>
> I now understand better what you were getting at.
> I committed some changes to allow optional/arbitrary extensions  
> (attributes) to the envelope, header and body elements (apart from the  
> header itself). The next artificial example shows what can be done:
>
> CL-SOAP 39 > (soap-call xmethods
>                         '((:username "foo") (:password "secret"))
>                         `((ns1::|getQuote|
>                            soapenv:|encodingStyle| ,+soap-enc-ns-uri+
>                            :|xmlns:ns1| ,ns)
>                           ((:|symbol| xsi::|type| "xsd:string")
>                            "AAPL"))
>                         :soap-action  
> "urn:xmethods-delayed-quotes#getQuote"
>                         :envelope-attributes '(:foo "1" :bar "2")
>                         :header-attributes '(:foo "1" :bar "2")
>                         :body-attributes '(:foo "1" :bar "2"))
> ;; SOAP CALL sending:
> <soapenv:Envelope  
> xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"  
> xmlns:xsd="http://www.w3.org/1999/XMLSchema"  
> xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance" FOO="1" BAR="2">
>   <soapenv:Header FOO="1" BAR="2">
>     <USERNAME>foo</USERNAME>
>     <PASSWORD>secret</PASSWORD>
>     </soapenv:Header>
>   <soapenv:Body FOO="1" BAR="2">
>     <ns1:getQuote  
> soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"  
> xmlns:ns1="urn:xmethods-delayed-quotes">
>       <symbol xsi:type="xsd:string">AAPL</symbol>
>       </ns1:getQuote>
>     </soapenv:Body>
>   </soapenv:Envelope>
> ;; SOAP CALL receiving: <?xml version='1.0' encoding='UTF-8'?>
> <soap:Envelope xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/'  
> xmlns:xsi='http://www.w3.org/1999/XMLSchema-instance'  
> xmlns:xsd='http://www.w3.org/1999/XMLSchema'  
> xmlns:soapenc='http://schemas.xmlsoap.org/soap/encoding/'  
> soap:encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'><soap: 
> Body><n:getQuoteResponse xmlns:n='urn:xmethods-delayed-quotes'><Result  
> xsi:type='xsd:float'>49.78</Result></n:getQuoteResponse></soap:Body></ 
> soap:Envelope>
> ((NS1:|getQuoteResponse| :|xmlns:n| "urn:xmethods-delayed-quotes")  
> ((:|Result| XSI:|type| "xsd:float") "49.78"))
>
> I hope that the API now covers what you need (you can add the  
> encodingStyle attribute manually).
>
> Is it possible for you to illustrate your points (this one or future  
> ones) using publically available SOAP web services (like the ones  
> listed on xmethods.net), that way we can write test code that  
> everybody can run while being sure we talk about exactly the same  
> things.
>
> I didn't just add the attribute you requested because (1) it is not  
> always necessary (for example for non-RPC calls) (2) it can be added  
> on the element inside the body as well (as far as I understand).
>
> BTW: how did you find out about this project, I thought it wasn't  
> visible anywhere ?
>
> Now I am off to parsing WSDL ;-)
>
> Sven
>
> On 09 Sep 2005, at 00:12, Carlos Ungil wrote:
>
>> Hello Sven,
>>
>> I was trying to reproduce the following message (generated using the  
>> perl module SOAP:Lite):
>>
>> <SOAP-ENV:Envelope  
>> xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance"  
>> xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"  
>> xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"  
>> xmlns:xsd="http://www.w3.org/1999/XMLSchema"  
>> SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/ 
>> encoding/"><SOAP-ENV:Header><AuthenticationInfo><userName>xxx</ 
>> userName><password>xxx</password><authentication/><locale/><timeZone/ 
>> ></AuthenticationInfo></SOAP-ENV:Header><SOAP-ENV:Body><namesp1: 
>> OpGetList  
>> xmlns:namesp1="urn:PRMS_ProblemMgmt_AIS"><Qualification>'Short  
>> Description' LIKE  
>> "Probl%"</Qualification></namesp1:OpGetList></SOAP-ENV:Body></SOAP- 
>> ENV:Envelope>
>>
>> Using my soap-envelope function, the following code
>>
>> (soap-call end-point
>>                               '(((:|AuthenticationInfo|)
>>                  ((:|userName|) "xxx")
>>                  ((:|password|) "xxx")
>>                  ((:|authentication|))
>>                  ((:|locale|))
>>                  ((:|timeZone|))))
>>                               `(((ns1::|OpGetList| :|xmlns:ns1| ,ns)
>>                  ((:|Qualification|) "'Short Description' LIKE  
>> \"Prob%\""))))
>>
>> produces the quite similar xml message
>>
>> <soapenv:Envelope  
>> xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"  
>> soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"  
>> xmlns:xsd="http://www.w3.org/1999/XMLSchema"  
>> xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance"><soapenv: 
>> Header><AuthenticationInfo><userName>xxx</userName><password>xxx</ 
>> password><authentication/><locale/><timeZone/></AuthenticationInfo></ 
>> soapenv:Header><soapenv:Body><ns1:OpGetList  
>> xmlns:ns1="urn:PRMS_ProblemMgmt_AIS"><Qualification>'Short  
>> Description' LIKE  
>> "Prob%"</Qualification></ns1:OpGetList></soapenv:Body></ 
>> soapenv:Envelope>
>>
>> I've just noticed that the perl-generated version contains two  
>> properties related to the encoding:
>> - SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"  
>> (I reproduced this in the lisp version)
>> - xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" (I  
>> didn't include that, but it worked the same)
>>
>> I don't know if those are "correct" soap messages, in any case they  
>> work. But in fact I've not tried to connect to the web service using  
>> the original cl-soap code, it might work as well.
>>
>> Cheers,
>>
>> Carlos
>>
>>
>




More information about the cl-soap-devel mailing list