Dechenjm / pysimplesoap

Automatically exported from code.google.com/p/pysimplesoap
0 stars 0 forks source link

SimpleXMLElement header required when using wsdl #78

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. given a wsdl that requires the header to provide credentials using 
namespaced tags ( http://dczorgwelzijn-test.qmark.nl/qmwise4/qmwise.asmx?wsdl )
2. given a dictionary with wsdl namespace in key values are removed so won't 
work
3. given a static string won't work 

What is the expected output? What do you see instead?
I can't get the namespace elements in the header when using the WSDL. I can fix 
up some of it when calling everything directly but that leaves me with handling 
all the response elements, which i prefer to be handled by the wsdl handler. 

What version of the product are you using? On what operating system?
1.07a on windows 7

Please provide any additional information below.
What gives me the fix was adding this to allow the header to contain a 
SimpleXMLElement and to include it directly: 
{{{
@@ -200,7 +200,10 @@
             for k, v in self.__call_headers.items():
                 ##if not self.__ns:
                 ##    header['xmlns']
-                header.marshall(k, v, ns=self.__ns, add_children_ns=False)
+                if isinstance(v,SimpleXMLElement):
+                    header.import_node(v)
+                else:
+                    header.marshall(k, v, ns=self.__ns, add_children_ns=False)

         if request_headers:
             header = request('Header' , ns=soap_namespaces.values(),)
}}}

This construct allows: 
{{{
namespace = 'http://questionmark.com/QMWISe/'
ns = 'qmw'
header = SimpleXMLElement('<Headers/>', namespace=namespace, prefix=ns)
security = header.add_child("Security")
security['xmlns:qmw']=namespace
security.marshall('ClientID','NAME',ns=ns)
security.marshall('Checksum','PASSWORD',ns=ns)
client['Security']=security
}}}

Original issue reported on code.google.com by remco.boerma on 17 Sep 2012 at 10:27

GoogleCodeExporter commented 9 years ago
The patch is on client.py, i forgot to mention the filename 

Original comment by remco.boerma on 17 Sep 2012 at 10:28

GoogleCodeExporter commented 9 years ago
Thank you!

I've given you commit rights so you can commit this and close this issue!

Please, if you can, add a test case ;-)

Original comment by reingart@gmail.com on 17 Sep 2012 at 4:29

GoogleCodeExporter commented 9 years ago
Thanks. I couldn't find a testcase that allows local wsdl. So i refered the 
wsdl document above in the test. Hope it will live on that server for a while. 

Original comment by remco.boerma on 18 Sep 2012 at 8:08

GoogleCodeExporter commented 9 years ago
Fixed in rev:4e8f17b1ce93 

Original comment by remco.boerma on 18 Sep 2012 at 8:13