Approximately 8 hours of my life was consumed by SOAP. Not the washy type SOAP, but rather, Simple Object Access Protocol. Yes, another nerdy post.

Python has a nice little library, called SOAPpy, which lets you generate SOAP requests. It seems to work, unless you’re accessing a .NET SOAP proxy. This, unfortunately, is what I was trying to do.

So it took about 6 hours to come up with the following 4 lines of code:

proxy = SOAPpy.SOAPProxy(‘http://whatever/webservice.asmx’, ‘http://whatever/namespace/’, ‘ http://whatever/Action’)
proxy.config.dumpSOAPOut = 1
proxy.config.buildWithNamespacePrefix = 0
response = proxy.Action(variable=value, variable2=value, variable3=product_name)


Line 1: You have to pass in the SOAPAction here, fully qualified. Otherwise you’ll get things such as “Object Reference” errors.
Line 2: This is great for debugging
Line 3: This line is not documented. Nobody suggests using it. Nobody talks about it. It is the most critical line and the one that took the longest to figure out. The problem is the SOAP request is not exactly what .NET is expecting; Python specifies the namespace with ‘ns1’ which I believe identifies the namespace. .NET chokes on this and dies.
Line 4: You need to specify the name of the variable, then the equals sign, then the value.