4

I'm currently using a WS where I send an XML Request to a url and then receive an XML Response. The request might look like the following:

<RequestColour>
...
</RequestColour>

The response looks like:

<ResponseColourOutput>
...
</ResponseColourOutput>

Which libraries should I use in Python to send those xml requests and receive the responses back?

1

3 Answers 3

5

You can use the urllib2 module that comes with Python to make requests to a URL that can consume this.

The Python website has a decent tutorial on how to use this module to fetch internet resources. The next step is learning how to generate/consume XML.

Related SO answers for those steps:

Sign up to request clarification or add additional context in comments.

Comments

1

I have posted a small example of plain XML request and response in Python here:

http://it.toolbox.com/blogs/lim/request-get-reply-and-display-xml-in-python-beauty-of-simplicity-49791

Please not that my example posts arbitrary XML and gets a valid XML but that informs you of an error because the content of the request was not recognized.

You could use your own URL and XML or adjust not to send XML request and just parse the response against the provided XML.

I would also suggest looking into eBays example for their x.Commerce XML API accessed from Python.

Hope this helps.

Comments

0

If the XML processing you do is simple, try looking at the built-in API, xml.etree.ElementTree.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.