packages feed

soap 0.1.0.3 → 0.1.0.4

raw patch · 2 files changed

+17/−9 lines, 2 filesPVP: minor bump suggested

API additions: PVP suggests at least a minor version bump

API changes (from Hackage documentation)

+ Web.SOAP.Service: flowNS :: Maybe Text -> Node -> Node

Files

soap.cabal view
@@ -2,7 +2,7 @@ -- see http://haskell.org/cabal/users-guide/  name:                soap-version:             0.1.0.3+version:             0.1.0.4 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
@@ -3,6 +3,7 @@     ( SOAPSettings(..)     , invokeWS     , invokeWS'+    , flowNS     ) where  import           Text.XML@@ -47,7 +48,7 @@           -> IO o          -- ^ response invokeWS' reqProc SOAPSettings{..} methodHeader h b = do     let headerNodes = toNodes h-    let bodyNodes = map (flowNS $ Just soapNamespace) (toNodes b)+    let bodyNodes = toNodes b      let doc = document $! envelope headerNodes bodyNodes     let body = renderLBS def $! doc@@ -89,18 +90,25 @@ envelope :: [Node] -> [Node] -> Element envelope header body =     Element-        "{http://schemas.xmlsoap.org/soap/envelope/}Envelope"+        (soapenv "Envelope")         def         ( if null header-            then [ NodeElement $! Element "{http://schemas.xmlsoap.org/soap/envelope/}Body" def body ]-            else [ NodeElement $! Element "{http://schemas.xmlsoap.org/soap/envelope/}Header" def header-                 , NodeElement $! Element "{http://schemas.xmlsoap.org/soap/envelope/}Body" def body+            then [ NodeElement $! Element (soapenv "Body") def body ]+            else [ NodeElement $! Element (soapenv "Header") def header+                 , NodeElement $! Element (soapenv "Body") def body                  ]         )+    where+        soapenv ln = Name ln (Just "http://schemas.xmlsoap.org/soap/envelope/") (Just "soapenv")  -- | 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.+--   This removes the necessity to litter your code with {<http://example.com/nonexistant/service/url.spamx>} in element names.+--+-- > foo = "test" .=: [ "shmest" .= "spam"+-- >                  , "spanish" .= "inquisition"+-- >                  ]+-- > foo' = map (flowNS $ Just "whatever") foo 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+flowNS _ (NodeElement (Element name@(Name _ ns' _) as cs))         = NodeElement $ Element name as                  $ map (flowNS ns') cs -- switch to new namespace and continue+flowNS _ node = node -- ignore non-elements