kartagis / pysimplesoap

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

Empty body for methods without argument ! #50

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1.call a soap method that doesnt require arguments
2.the call generates an empty soap:body xml
3.the soap server excepts

What is the expected output? What do you see instead?
the expected output is a call of the method without arguments

What version of the product are you using? On what operating system?
PySimpleSOAP-1.05a.win32.exe

Please provide any additional information below.
output of the pysimplesoap client:
"""
POST http://localhost:22222/?wsdl
SOAPAction: "RecuperaEstadoDispositivos"
Content-length: 270
Content-type: text/xml; charset="UTF-8"

<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" 
xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-i
nstance">
<soap:Header/>
<soap:Body>

</soap:Body>
</soap:Envelope>
date: Wed, 08 Feb 2012 18:21:09 GMT
status: 500
content-length: 59
content-type: text/plain
server: WSGIServer/0.1 Python/2.6.6
A server error occurred.  Please contact the administrator.
================================================================================
ERROR:A server error occurred.  Please contact the administrator.
Traceback (most recent call last):
  File "client_ws1.py", line 6, in <module>
    print client.RecuperaEstadoDispositivos()
  File "C:\Python26\Lib\site-packages\pysimplesoap\client.py", line 140, in <lambda>
    return lambda *args, **kwargs: self.wsdl_call(attr,*args,**kwargs)
  File "C:\Python26\Lib\site-packages\pysimplesoap\client.py", line 289, in wsdl_call
    response = self.call(method, *params)
  File "C:\Python26\Lib\site-packages\pysimplesoap\client.py", line 186, in call
    response = SimpleXMLElement(self.xml_response, namespace=self.namespace)
  File "C:\Python26\Lib\site-packages\pysimplesoap\simplexml.py", line 133, in __init__
    self.__document = xml.dom.minidom.parseString(text)
  File "C:\Python26\lib\site-packages\pyxml-0.8.4-py2.6-win32.egg\_xmlplus\dom\minidom.py", line 1925, in parseString
    return expatbuilder.parseString(string)
  File "C:\Python26\lib\site-packages\pyxml-0.8.4-py2.6-win32.egg\_xmlplus\dom\expatbuilder.py", line 942, in parseString
    return builder.parseString(string)
  File "C:\Python26\lib\site-packages\pyxml-0.8.4-py2.6-win32.egg\_xmlplus\dom\expatbuilder.py", line 223, in parseString
    parser.Parse(string, True)
xml.parsers.expat.ExpatError: syntax error: line 1, column 0

C:\Python26\Lib\site-packages\biokit\demo\tsev2_demo\wsv2>"""

and wsdl file attached.

Original issue reported on code.google.com by kpo...@gmail.com on 8 Feb 2012 at 6:27

Attachments:

GoogleCodeExporter commented 8 years ago
This is a feature :-)

The problem is that some webservices need empty the request when no parameters 
(ie. jboss), and some other do expect an empty tag (ie. oracle).

That's why this version added an optional parameter to SoapClient constructor: 
soap_server. 

Specify "oracle" as the server, and it would send the empty Body tag:
SoapClient(..., soap_server="oracle")

Please let me know if this works, and if you can attach the full trace (with 
http headers showing what kind of server you are using)

Original comment by reingart@gmail.com on 9 Feb 2012 at 10:17

GoogleCodeExporter commented 8 years ago
With soap_server='oracle' it did work yes, I got this body:

<soap:Body>
    <RecuperaEstadoDispositivos xmlns="tns">
    </RecuperaEstadoDispositivos>
</soap:Body>

Thanks for the tip !

Original comment by kpo...@gmail.com on 10 Feb 2012 at 11:50

GoogleCodeExporter commented 8 years ago

Original comment by reingart@gmail.com on 10 Feb 2012 at 10:53

GoogleCodeExporter commented 8 years ago
It's still not a empty element, the above has a body of "\n  ". Ie in xml these 
are not equvalent:

 -  '<foo> </foo>'
 -  '<foo></foo>'

The xml string should be something like:
<%(soap_ns)s:envelope xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" 
    xmlns:xsd="http://www.w3.org/2001/xmlschema" 
    xmlns:%(soap_ns)s="%(soap_uri)s"><%(soap_ns)s:header/><%(soap_ns)s:body><%(method)s xmlns="%(namespace)s"></%(method)s></%(soap_ns)s:body></%(soap_ns)s:envelope>"""

The above works for me.

Also, instead of using an argument of soap_server, use a meaningful name? Ie. i 
need the same but it's not an oracle server.
 (Poor) example: always_include_element=True

Original comment by Frej.Soya on 28 Apr 2012 at 2:55