From: Florent G. <li...@fg...> - 2011-08-22 16:28:09
|
Hi, The current version of eXist in the trunk does not support passing atomic values to http:send-request(). Even thougn most of the information is passed through the http:request param of that function, the spec defines a 3-params function signature: http:send-request($request as element(http:request)?, $href as xs:string?, $bodies as item()*) as item()+ The content of bodies represent the body of the HTTP request (in case of a POST or PUT, for instance). It can contain several items, in case of a multipart request. An XML or HTML payload is represented by a document or an element node. Textual content is passed as an xs:string, and binary as an xs:base64Binary item. In the two later cases, eXist throws a ClassCastException. The reason is in EXistSequence#serialize, line 98: NodeValue next = (NodeValue)itSequence.nextItem(); As long as we are passing nodes, everything is fine. But as soon as we use the possibility to pass a string or a binary item, this blows up because those are not nodes. Unfortunately, I don't know how to adapt that code in order to send atomic values (once again, only strings and binary items) to an eXist Serializer object. To reproduce the problem... This one works (the text body is passed as a text node, directly as the child of http:body): import module namespace http = "http://expath.org/ns/http-client"; declare variable $uri := 'http://h2oconsulting.be/tools/dump'; http:send-request( <http:request href="{ $uri }" method="post"> <http:body media-type="text/plain">Hello, eXist!</http:body> </http:request>) but this one fails, because the text body is passed as a string in the 3d param and EXistSequence tries to cast it to a NodeValue (but it is a StringValue): import module namespace http = "http://expath.org/ns/http-client"; declare variable $uri := 'http://h2oconsulting.be/tools/dump'; http:send-request( <http:request href="{ $uri }" method="post"> <http:body media-type="text/plain"/> </http:request>, (), 'Hello, eXist!') Any idea how to push the StringValue to the Serializer object? Regards, -- Florent Georges http://fgeorges.org/ http://h2oconsulting.be/ |