I am trying to convert a response from http-conduit to an XML document via an XML feed.
The doPost function accepts an XML document and sends it to the server. The server responds with an XML document.
doPost queryDoc = do runResourceT $ do manager <- liftIO $ newManager def req <- liftIO $ parseUrl hostname let req2 = req { method = H.methodPost , requestHeaders = [(CI.mk $ fromString "Content-Type", fromString "text/xml" :: Ascii) :: Header] , redirectCount = 0 , checkStatus = \_ _ -> Nothing , requestBody = RequestBodyLBS $ (renderLBS def queryDoc) } res <- http req2 manager return $ res
The following works and returns '200':
let pingdoc = Document (Prologue [] Nothing []) (Element "SYSTEM" [] []) [] Response status headers body <- doPost pingdoc return (H.statusCode status)
However, when I try to parse the Response body using xml-conduit, I have problems:
Response status headers body <- doPost xmldoc let xmlRes' = parseLBS def body
The resulting compilation error:
Couldn't match expected type `L.ByteString' with actual type `Source m0 ByteString' In the second argument of `parseLBS', namely `body' In the expression: parseLBS def body In an equation for `xmlRes'': xmlRes' = parseLBS def body
I tried connecting Source from http-conduit to the xml feed using $ = and $$, but I did not succeed.
Does anyone have any hints to point me in the right direction? Thanks in advance.
Neil
source share