kartagis / pysimplesoap

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

Can't set attributes for request tag without children #170

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
Bug is very similar as a bug number 89. But it appears when request tag has no 
children.

What steps will reproduce the problem?

I have a soap service and I try to make SOAP client.
I'm not using WSDL file.

This is my code:
***********************************************************************
from pysimplesoap.simplexml import SimpleXMLElement
from pysimplesoap.client import SoapClient
from pysimplesoap.client import SoapFault

client = SoapClient(
    location="http://127.0.0.1:8888/services/asrWS",
    action='http://127.0.0.1:8888/services/asrWS',
    namespace="http://www.asr.ru/asr",
    trace=True, ns="asr", exceptions=True)

try:
    # bug is present
    param = SimpleXMLElement('<createSubscriberRequest msisdn="1" iccid="1" imsi="1" vin="1"/>')

    # no bug
    #param = SimpleXMLElement('<createSubscriberRequest msisdn="1" iccid="1" imsi="1" vin="1"><span/></createSubscriberRequest>')

    print(param.as_xml())
    response = client.call('createSubscriberRequest', param)
    result = response.AddResult
    print(repr(result))
except SoapFault as ex:
    print("ServerFault:", ex.faultcode, ex.faultstring)
***********************************************************************

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

Expectation:

print(param.as_xml()):
<?xml version="1.0" encoding="UTF-8"?><createSubscriberRequest iccid="1" 
imsi="1" msisdn="1" vin="1"/>

SOAP Message:
<?xml version="1.0" encoding="UTF-8"?><soapenv:Envelope 
xmlns:asr="http://www.asr.ru/asr" 
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Header/>
<soapenv:Body>
    <asr:createSubscriberRequest iccid="1" imsi="1" msisdn="1" vin="1"/>
</soapenv:Body>
</soapenv:Envelope>

In Real:

print(param.as_xml()):
<?xml version="1.0" encoding="UTF-8"?><createSubscriberRequest iccid="1" 
imsi="1" msisdn="1" vin="1"/>

SOAP Message:
<?xml version="1.0" encoding="UTF-8"?><soapenv:Envelope 
xmlns:asr="http://www.asr.ru/asr" 
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Header/>
<soapenv:Body>
    <asr:createSubscriberRequest>
    </asr:createSubscriberRequest>
</soapenv:Body>
</soapenv:Envelope>

But if if have at least one child in request tag it's ok:
In Real:

print(param.as_xml()):
<?xml version="1.0" encoding="UTF-8"?><createSubscriberRequest iccid="1" 
imsi="1" msisdn="1" vin="1"><span/></createSubscriberRequest>

SOAP Message:
<?xml version="1.0" encoding="UTF-8"?><soapenv:Envelope 
xmlns:asr="http://www.asr.ru/asr" 
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Header/>
<soapenv:Body>
    <asr:createSubscriberRequest iccid="1" imsi="1" msisdn="1" vin="1">
        <span/>
    </asr:createSubscriberRequest>
</soapenv:Body>
</soapenv:Envelope>

What version of the product are you using? On what operating system?
Python - 3.4.2
PySimpleSOAP - 1.13

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

Original issue reported on code.google.com by konovalo...@gmail.com on 20 Jan 2015 at 11:45