packages feed

soap 0.1.0.0 → 0.1.0.1

raw patch · 3 files changed

+18/−18 lines, 3 filesPVP: major bump suggested

API removals or changes: PVP suggests a major version bump

API changes (from Hackage documentation)

- Web.SOAP.Types: class ToAttribute a
- Web.SOAP.Types: readContent :: Read a => Cursor -> a
- Web.SOAP.Types: toAttribute :: ToAttribute a => a -> (Name, Text)

Files

soap.cabal view
@@ -2,7 +2,7 @@ -- see http://haskell.org/cabal/users-guide/  name:                soap-version:             0.1.0.0+version:             0.1.0.1 synopsis:            SOAP client tools description:         Tools to build SOAP clients using xml-conduit. homepage:            https://bitbucket.org/dpwiz/haskell-soap
src/Web/SOAP/Service.hs view
@@ -35,17 +35,19 @@          -> IO o          -- ^ response  invokeWS SOAPSettings{..} methodHeader h b = do-    let doc = document $! envelope (toNodes h) (toNodes b)-    let stripEmptyNS = TL.replace " xmlns=\"\"" ""-    let body = stripEmptyNS . renderText def $! doc+    let headerNodes = toNodes h+    let bodyNodes = map (flowNS $ Just soapNamespace) (toNodes b) +    let doc = document $! envelope headerNodes bodyNodes+    let body = renderLBS def $! doc+     putStrLn "Request:"-    TL.putStrLn . stripEmptyNS . renderText def { rsPretty = True } $! doc+    TL.putStrLn . renderText def { rsPretty = True } $! doc      request <- parseUrl soapURL     res <- withManager $ httpLbs request { method          = "POST"                                          , responseTimeout = Just 15000000-                                         , requestBody     = RequestBodyLBS $ TLE.encodeUtf8 body+                                         , requestBody     = RequestBodyLBS body                                          , requestHeaders  = [ ("Content-Type", "text/xml; charset=utf-8")                                                              , ("SOAPAction", TE.encodeUtf8 methodHeader)                                                              ]@@ -80,3 +82,10 @@         [ NodeElement $! Element "{http://schemas.xmlsoap.org/soap/envelope/}Header" def h         , NodeElement $! Element "{http://schemas.xmlsoap.org/soap/envelope/}Body" def b         ]++-- | Little helper to apply default service namespace to body nodes and their descendants.+--   This removes the necessity to flood your code with {http://vendor.silly.web/Service.spamx} in element names.+flowNS :: Maybe Text -> Node -> Node+flowNS ns (NodeElement (Element (Name name Nothing prefix) as cs)) = NodeElement $ Element (Name name ns prefix) as $ map (flowNS ns) cs  -- update element ns and continue+flowNS ns (NodeElement (Element name@(Name _ ns' _) as cs))        = NodeElement $ Element name as                  $ map (flowNS ns') cs -- switch to new namespace and continue+flowNS ns node = node -- ignore non-elements
src/Web/SOAP/Types.hs view
@@ -2,8 +2,7 @@  module Web.SOAP.Types     ( ToNodes(..), (.=:), (.=)-    , ToAttribute(..)-    , FromCursor(..), readT, readC, readContent, Dict, asDict+    , FromCursor(..), readT, readC, Dict, asDict     ) where  import           Data.Text (Text)@@ -52,14 +51,6 @@ (.=) :: Name -> Text -> Node n .= t = head $ toNodes (n, toNodes t) --- ** Construct attributes--class ToAttribute a where-    toAttribute :: a -> (Name, Text)----instance (ToAttribute a) => (Name, Text) where---    toAttribute (n, t) = (n, t)- -- * Extract data from XML cursor  class FromCursor a where@@ -75,8 +66,8 @@ readC n c = read . T.unpack $ readT n c {-# INLINE readC #-} -readContent :: (Read a) => Cursor -> a-readContent = error . show . T.unpack . T.concat . content+--readContent :: (Read a) => Cursor -> a+--readContent = read . T.unpack . T.concat . content  -- ** Multi-element extraction.