kakaka88 / pysimplesoap

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

Remove xmlns-tags for child-nodes - simplexml.py #151

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. By using a Webservice, the namespace (xmlns="mynamespace") is set to each 
node. The Webservice is not useable by sending the request in this way. 
2. Connect the WebService link this:
client    = SoapClient(
         wsdl            = WSDL_URL
        ,location        = WSDL_URL
        ,ns              = 'mynamespace'
        ,exceptions      = True
        ,http_headers    = {'Authorization':'Basic %s' %encoded}
        ,trace           = True
        ,soap_server     = 'oracle'
        )
client.mymethod(params={u'key':'value'})

What is the expected output? What do you see instead?
Expected output:

<?xml version="1.0" encoding="UTF-8"?>
    <soapenv:Envelope xmlns:mynamespace="http://.../" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
        <soapenv:Header/>
        <soapenv:Body>
            <mynamespace:mymethod>
                <params>
                    <key>value</key>
                </params>
            </mynamespace:mymethod>
</soapenv:Body>
</soapenv:Envelope>

Current output:
<?xml version="1.0" encoding="UTF-8"?>
    <soapenv:Envelope xmlns:mynamespace="http://.../" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
        <soapenv:Header/>
        <soapenv:Body>
            <mynamespace:mymethod>
                <params>
                    <key xmlns="http://.../">value</key>
                </params>
            </mynamespace:mymethod>
</soapenv:Body>
</soapenv:Envelope>

What version of the product are you using? On what operating system?
1.14

Please attach the related WSDL (if any), a small code fragment to reproduce
and provide any additional information below.

Solution that works for me:
    Uncomment Lines 74 and 75 in simplexml.py:
        #if ns:
        #    element.setAttribute("xmlns", ns)

My wish:
    A Parameter in the SoapClient-Connect to disable the xmlns for the nodes.

Original issue reported on code.google.com by karsten....@gmail.com on 23 Jul 2014 at 11:48

GoogleCodeExporter commented 8 years ago
The parameter in the constructor to control the xml response (dialect) is 
soap_server.
Which one you're using?
Sometimes this can be deducted from the WSDL, could you attach it?

Original comment by reingart@gmail.com on 23 Jul 2014 at 8:59

GoogleCodeExporter commented 8 years ago
I use "soap_server = 'Oracle'" as described at the top of the post.
BUT: I mean the OUTPUT, which pysimplesoap generates to send the PostRequest. 
Not the Response from the WebService!

I'm not able to attach the WSDL, becaus ist a customer-Projekt which i can not 
publish - i'm sorry.

Original comment by karsten....@gmail.com on 28 Jul 2014 at 7:20

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
I found a temporary solution that suited my project's needs. In simplexml.py, I 
commented out line 75 ~#element.setAttribute("xmlns", ns)~ and added ~pass~ 
beneath it, tildes not included.

To be specific, it was inside the add_child() function, nested into else-if-if.
(see below)

add_child(self, name, text=None, ns=True):
  if not ns or self.__ns is False:
    #stuff
  else:
    #stuff
    if isinstance(ns, basestring):
      #stuff
      if ns:
        # element.setAttribute("xmlns", ns)
        pass

Original comment by ilb...@gmail.com on 9 Jun 2015 at 9:34