Tools to build SOAP clients using xml-conduit.

A mildly-complicated example:

import Network.SOAP
import Network.SOAP.Transport.HTTP

import Text.XML.Writer
import Text.XML.Stream.Parse as Parse
import           Data.Text (Text)
import qualified Data.Text as T

main :: IO ()
main = do
    -- Initial one-time preparations.
    transport <- initTransport "http://example.com/soap/endpoint" id (iconv "cp-1251")

    -- Making queries
    activeStaff <- listStaff transport True
    print activeStaff

data Person = Person Text Int deriving Show

listStaff :: Transport -> Bool -> IO [Person]
listStaff t active = invokeWS t "urn:dummy:listStaff" () body parser
    where
        body = element "request" $ element "listStaff" $ do
                   element "active" active
                   element "order" $ T.pack "age"
                   element "limit" (10 :: Int)

        parser = StreamParser $ force "no people" $ tagNoAttr "people" $ Parse.many parsePerson

        parsePerson = tagName "person" (requireAttr "age") $ \age -> do
                          name <- Parse.content
                          return $ Person name (read . T.unpack $ age)

Notice: to invoke HTTPS services you need to initialize a transport from soap-tls or soap-openssl.

Full examples available at source repo: https://bitbucket.org/dpwiz/haskell-soap/src/HEAD/soap/examples/

Changes

0.2.3.2:

* Unbreak the build with GHC 7.8.

0.2.3.1:

* Sprinkle some CPP to prepare for next http-client.

0.2.3.0:

+ Add monadic request and response processors.
* Deprecate pure processors.

0.2.2.7:

! Add missing export for parser runner.

0.2.2.6:

* Extract parser runner. `invokeWS` now is a mere default pipeline.

0.2.2.5:

* Drop upper bounds entirely.

0.2.2.4:

! Haddock breaks on LANGUAGE in example.

0.2.2.3:

* Raise http-client upper boundary.

0.2.2.2:

! Fix missing imports after conduit stopped reexporting in 1.1.

0.2.2.1:

+ Add basic http transport initializer to exports.

0.2.2:

* Switch to http-client transport.
Bring soap-tls or soap-openssl to use HTTPS connections.

0.2.1.3:

* Cabal-only tweaks: remove -O2, add changelog.

0.2.1.2:

+ Add timeout option to confTransport.

0.2.1.1:

! Pin http-conduit version to 1.9.x.

0.2.1.0:

* Throw SOAPParsingError instead of plain error.
* Update SOAPFault detection.

0.2.0.4:

+ Add configurator-based transport initialization.

0.2.0.3:

! Switch to a recent http-conduit version.

0.2.0.2:

* Detect SOAPFault in response and throw a proper Exception.

0.2.0.1:

+ Tag content helpers for stream parsers.
+ Dict helper for cursor parsers.
+ Document-based parser for "medium rare" cursor parsers.
+ Request and response tracing helpers.

0.2:

* Switch to xml-conduit-writer for more clean serializers.
+ Pluggable transports.
+ Raw and streaming parsers.

0.1:

Initial implementation, somewhat inflexible and warty,
but working with diverse services.
comments powered byDisqus