Using xml: Interfacing to the LinkPoint API with Python – Sending XML Over SSL with Authentication on newest questions tagged xml – Stack Overflow

I’m trying to make a successful connection to the LinkPoint gateway using Python. For those of you unfamiliar with their API you get a .pem file you use for authentication purposes.

I’m having trouble using this file and creating a secure connection over SSL.

According to their API documentation (which leaves a lot to be desired, btw) I believe the configuration should look similar to below:

HOST = 'secure.linkpt.net'
API_URL = 'https://secure.linkpt.net/lpc/servlet/lppay'
PORT = 1129
cert_key = my_cert_key.pem

Using this information and a valid XML string how can I create this connection?

I’m pretty new to HTTP connections in Python. I’ve successfully implemented connections with other APIs using a POST with urllib2. Naturally, my first attempt started with a similar approach hoping I could stumble on to a solution.

Something like:

headers = { 'User-Agent'     : 'Rico',
            'Content-type'   : 'text/xml; charset=\"UTF-8\"',
            'Content-length' : len(self.xml_string),
          }

# POST to First Data (Link Point)
req = urllib2.Request(API_URL, self.xml_string, headers)
response = urllib2.urlopen(req)
self.handleResponse(response.read())

I had little hopes this would work as I didn’t provide anything about the cert_key or the PORT.

After this attempt I tried to use a similar approach as I found from a solution from another stackoverflow post. Unfortunately I wasn’t able to get far with this as I don’t have ca_certs or cert files (that I know of).

I’ve tried to use Requests but can’t find the documentation/examples for me to make sense of it.

I’ve also tried to use Twisted, and I really hoped I could do something with this but this feels like trying to open a door with a wrecking ball. It just feels like overkill to me. I just need a simple connection/request/response…this seems overly complicated for that.

My next attempt was going to be PycURL, but have confronted enough despair during this process I thought I’d come here to see if someone had some good suggestions before diving into this.

If you think I should re-visit one of these tools please let me know. I didn’t spend a great deal of time with any of these – just enough to get my feet wet. If you could also point me to a good example or detailed documentation that would be fantastic.

Also, I’d prefer not to use the standard SSL library to build the connection myself – I don’t want to reinvent the wheel if I don’t have to.

See Answers


source: http://stackoverflow.com/questions/11569135/interfacing-to-the-linkpoint-api-with-python-sending-xml-over-ssl-with-authent
Using xml: using-xml



online applications demo