I am looking for a python SOAP 1.2 client but it seems that it does not exist . All of the existing clients are either not maintainted or only compatible with SOAP 1.1:
The zeep library supports both SOAP 1.1 and 1.2 as long as the service's WSDL properly indicates it.
WSF/Python is supporting SOAP 1.2.
INTRODUCTION
WSF/Python is the Python language extension to WSO2 WSF/C [http://www.wso2.org/projects/wsf/c]. This version enables you to consume/provide Web Services both with REST and SOAP.
- Support for REST
- Support for SOAP 1.1
- Support for SOAP 1.2
For downloading, you don't have to register. Just click "submit" at the very bottom.
Samples can be found within the downloaded archive, eg:
LOG_DIR = '/tmp/'
LOG_LEVEL = 4
WSFC_HOME = '/opt/wso2/wsf_c'
END_POINT = 'http://localhost:9090/axis2/services/echo/echoString'
if __name__ == '__main__':
message = """
<ns1:echoString xmlns:ns1="http://ws.apache.org/axis2/services/echo">
<text>Hello World!</text>
</ns1:echoString>
"""
try:
client = wso2.wsf.WSClient({
'to':END_POINT,
'WSF_LOG_DIR':LOG_DIR,
'WSF_LOG_LEVEL':LOG_LEVEL,
'WSFC_HOME':WSFC_HOME,
})
print 'Sending: ' + message
response = client.request(message)
if response is not None:
print 'Respose: ' + response + '\n'
else:
print 'Error occurred!'
except wso2.wsf.WSFault, e:
print 'Exception occurred:'
print e
If you are really wanting to use SOAP 1.2 even though it is not used as a standard as yet, I reckon I can post an answer that requires some work (all for the greater good :)
).
I recommend that you use gSOAP:
gSOAP - a easy-use, cross-platform toolkit for C/C++ lovers to develop XML-based Web services and XML parsers. Although it is well-known as a Web service development toolkit and has been proved its good performance, it can also be used to create high-performance XML parsers, serializers and deserializers from XML schemas or C/C++ structs/classes. My experimental results demonstrate that the XML parsers generated using gSOAP toolkit run several times faster than xerces-c parsers in either DOM or SAX mode.
Now, I wish it were that easy. Due to gSOAP being a C++ library, you are going to have to wrap it to be able to use it in Python.
One way of wrapping the library is to use a tool by the name of SWIG (Simplified Wrapper and Interface Generator). This tool automatically wraps C/C++ libraries for use in high level languages, for example (you guessed it) Python.
I also recommend you read this PDF file (from page 14) on implementing gSOAP with C++. It is very helpful.
Using this solution, you can utilize a well looked after library, SOAP 1.2 and a very nice performance ratio. I think you will be quite happy with the results.
I have had the very similar problem some years ago and I have solved it by using Jython.
If there is no existed implementation of SOAP 1.2 for Python, you may be interested in Jython, which seamlessly integrates you with the Java platform. It means, you can use any of the existed SOAP 1.2 Java classes and just import it into your Jython program. Your Jython program is just your Python program, but you can import Java classes.
Jython itself includes almost all of the modules in the standard Python programming language distribution, but be sure that your program does not use any special non-standard Python library.
Example: say, you have Jython installed (it is free and Open Source) and your Python program is called myprog.py and you want use Java class CLASSNAME:
1) import required Java class inserting import CLASSNAME
into your myprog.py
2) run jython myprog.py
Even though this question has an accepted answer, there's a few notes I'd like regarding suds.
I'm currently writing some code for interfacing with .tel community hosting for work and I needed a Python SOAP library, and suds was pretty much ideal except for its lack of support for SOAP 1.2.
I managed to hack around the problem as for my purposes, SOAP 1.1 and SOAP 1.2 share enough in common that I was able to simply patch suds to use the SOAP 1.2 envelope namespace. I outlined what I did in this gist: https://gist.github.com/858851
As it's worth reproducing here, here's the code:
from suds.client import Client
from suds.bindings import binding
import logging
USERNAME = 'username'
PASSWORD = 'password'
# Just for debugging purposes.
logging.basicConfig(level=logging.INFO)
logging.getLogger('suds.client').setLevel(logging.DEBUG)
# Telnic's SOAP server expects a SOAP 1.2 envelope, not a SOAP 1.1 envelope
# and will complain if this hack isn't done.
binding.envns = ('SOAP-ENV', 'http://www.w3.org/2003/05/soap-envelope')
client = Client('client.wsdl',
username=USERNAME,
password=PASSWORD,
headers={'Content-Type': 'application/soap+xml'})
# This will now work just fine.
client.service.someRandomMethod()
If I've time, I'm planning on submitting a patch to suds to allow the version of SOAP to be used to be specified, and to add enough missing functionality to make it useful.