[Haskell-beginners] soap client python -> haskell

PICCA Frederic-Emmanuel frederic-emmanuel.picca at synchrotron-soleil.fr
Fri Feb 23 15:11:27 UTC 2018


Hello, I try to reproduce this kind of python code into haskell


--- python -- whcih use the suds module

        cj = CookieJar()
        url_opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj))

        transport = HttpAuthenticated(username=self.getIspybUserName(),
                                      password=self.getIspybPassWord())
        service_name = "ToolsForCollectionWebService"
        url = "http://195.221.10.20/ispyb-ws/ispybWS/ToolsForCollectionWebService?wsdl"

        collectionWSClient =  Client(url, transport=transport, timeout=3)
        collect_params = collectionWSClient.service.findDataCollection(dataCollectionId)---
---

Has you can see, I create a Transport whcih need an Authentification and also I need to use a cookieJar in oder to manage the connection.
The a soap client is instanciated from the url and with this transport.

Then the findDatacollection service is called.

Now I would like to reproduce this with Haskell and the soap package (or not if it is easier without)


I started like this

getDataCollection :: Transport -> Int -> IO Response
getDataCollection t i = invokeWS t url () body parser
    where
      url = "http://195.221.10.20/ispyb-ws/ispybWS/ToolsForCollectionWebService?wsdl" -- ?wsdl/findDatacollection"

      body = elementA "ToolsForCollectionWebService" [("xmlns", "findDataCollection")]
             $ element "dataCollectionID" i

      parser = StreamParser
               . flaxTag ""
               $ response

      response = Response
                 <$> flaxContent "filePath"


main :: IO ()
main = do
    -- Initial one-time preparations.
    transport <- initTransportWithM defaultManagerSettings url pure pure

    response <- getDataCollection transport dataCollectionID

    print response


And When I run this I have this message

autoprocessing-exe: HttpExceptionRequest Request {
  host                 = "xxx.xxx.xxx.xxx"
  port                 = 80
  secure               = False
  requestHeaders       = [("Content-Type","text/xml; charset=utf-8"),("SOAPAction","http://195.221.10.20/ispyb-ws/ispybWS/ToolsForCollectionWebService?wsdl")]
  path                 = "/ispyb-ws/ispybWS/ToolsForCollectionWebService"
  queryString          = ""
  method               = "POST"
  proxy                = Nothing
  rawBody              = False
  redirectCount        = 10
  responseTimeout      = ResponseTimeoutMicro 15000000
  requestVersion       = HTTP/1.1
}
 TlsNotSupported

I know that I do not want the https, the url is  http and not https.

now I do not know how to modify this in order to deal with the authentification and the cookiesJar.

It seems here that proxy is Nothing so I hope thqht it will use the http[s]_proxy environment variable.


thanks for your help.


Frederic


More information about the Beginners mailing list