Hi, In addition, you might be interested in the following (not been maintained for years and never been completely implemented, but there was something WRT multipart, if I remember correctly):
https://github.com/fgeorges/expath-http-client-ml/blob/master/src/http-client.xq Regards, -- Florent Georges http://fgeorges.org/ http://h2oconsulting.be/ On 10 February 2015 at 07:29, Raghu wrote: > Hi All, > > I'm calling a web service from my xquery and the response I'm getting is a > multipart response with two parts. I need the binary content(pdf) in the > second part to be stored in Marklogic, using xdmp:document-insert(), but I'm > unable to do that, I'm getting the following errors > > > If I use xdmp:document-insert ($uri,$secondPart) it says ARG2 IS NOT A NODE > > If I use xdmp:document-insert ($uri,document { $secondPart } ) the query > times out > > If I use binary{$secondPart} then it says invalid xdmp:cast exception > > If I use xdmp:multipart-decode($boundary-value, $multipart-response[2]) then > I get xdmp:invalid multipart > > How do I parse a mutlipart response in xquery? What is the right way to do > this? > Please help me out here. > > (: Logic I've used to parse the multipart response is below :) > > let $boundary-value := fn:concat('--', > fn:substring-after($multipart-response[1]/http:headers/http:content-type, > 'application/x-multipart-mixed;boundary=')) > > let $multipart-responseStr := > xdmp:binary-decode($multipart-response[2], 'UTF-8') > > let $tokens := fn:tokenize($multipart-responseStr, > $boundary-value) > > let $secondPart := fn:substring-after($tokens[3], 'Content-Type: > application/pdf;charset=UTF-8') > > > Thanks in advance! > > > > > _______________________________________________ > General mailing list > [email protected] > http://developer.marklogic.com/mailman/listinfo/general > _______________________________________________ General mailing list [email protected] http://developer.marklogic.com/mailman/listinfo/general
