"Raw" calls are supported (using SimpleXMLElement objects), attached is an
example

Are you using an updated web2py?

You should have to debug and see if it is going thru line 193 of
gluon.contrib.pysimplesoap.client:

        if parameters and isinstance(parameters[0], SimpleXMLElement):

If it is not entering that block, maybe you're using different versions of
the soap library, or from different locations.
The error you report means that the xml element object is not being
converted to xml bytes (string) correctly.

Best regards


Mariano Reingart
http://www.sistemasagiles.com.ar
http://reingart.blogspot.com

On Fri, Sep 26, 2014 at 5:05 PM, Dave S <snidely....@gmail.com> wrote:

>
> I've let this sit for a while because it is definitely less urgent than
> some of the other stuff I'm working on, but I'm still interested in the
> answer and how to talk to this odd target.
>
> /dps
>
>
> On Tuesday, August 12, 2014 4:00:24 PM UTC-7, Dave S wrote:
>>
>> Hmmm, I'm not quite there yet.
>>
>>
>>   client = SoapClient(
>>     location = ws_location,
>>     action = ws_action, # SOAPAction
>>     namespace = ws_namespace,
>>     soap_ns='soap', ns = False, exceptions=True,
>>     http_headers={'Authorization': "Basic %s" % encoded},
>>     trace=True)
>>   params =  SimpleXMLElement("""<?xml version="1.0" encoding="UTF-8"?>
>>       <UDIService><control>DON</control><action></action>
>>                       <node>25 C0 F0 1</node><flag>65531</flag>
>>       </UDIService>""")
>>   response = client.call('service',params)
>>
>>
>> When I run it, I get an error on the console, from rocket, presumably
>> during the 'send' part of client.call():
>>
>> ERROR:Rocket.Errors.Thread-2:Traceback (most recent call last):
>>
>>   File "/home/david/Documents/web2py/gluon/rocket.py", line 1337, in run
>>     self.run_app(conn)
>>   File "/home/david/Documents/web2py/gluon/rocket.py", line 1851, in
>> run_app
>>     self.write(data, sections)
>>   File "/home/david/Documents/web2py/gluon/rocket.py", line 1773, in
>> write
>>     self.conn.sendall(data)
>>   File "/usr/lib/python2.7/socket.py", line 224, in meth
>>     return getattr(self._sock,name)(*args)
>>
>> TypeError: must be convertible to a buffer, not SimpleXMLElement
>>
>>
>>
>> I believe this happening after I get past client.py line #193 (in
>> call()), and in fact I think I'm at line #240. --> send() which does the
>> HTTP request at line #268.
>>
>> Do I need to provide a logger instance to catch all the debug info?   I
>> am a novice at Python logging, being too given to just use print and watch
>> the console.
>>
>> /dps
>>
>>  --
> Resources:
> - http://web2py.com
> - http://web2py.com/book (Documentation)
> - http://github.com/web2py/web2py (Source code)
> - https://code.google.com/p/web2py/issues/list (Report Issues)
> ---
> You received this message because you are subscribed to the Google Groups
> "web2py-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to web2py+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
# -*- coding: utf-8 -*-
# intente algo como

from gluon.tools import Service
service = Service()

def call():
    session.forget()
    return service()

def index(): return dict(message="hello from webservice.py")

@service.soap('MyAdd',returns={'result':int},args={'a':int,'b':int,})
def add(a,b):
    return a+b

@service.soap('raw',returns={'result': bool},args={'control':str, 'action':str, 'node': str, 'flag': str})
def raw(control, action, node, flag):
    return True

def test():
    # "raw" (xml) remote procedure call:
    from gluon.contrib.pysimplesoap.client import SoapClient,SimpleXMLElement
    client = SoapClient(
        location = "http://localhost:8000/prueba/webservice/call/soap";,
        action = "", # ws_action, # SOAPAction
        namespace = "ns", #ws_namespace,
        soap_ns='soap', ns = False, exceptions=True, 
        http_headers={'Authorization': "Basic %s" % ""},
        trace=True)
    params =  SimpleXMLElement("""<?xml version="1.0" encoding="UTF-8"?>
      <UDIService><control>DON</control><action></action>
                      <node>25 C0 F0 1</node><flag>65531</flag>
      </UDIService>""")
    response = client.call('raw',params)
    return response.as_xml()

Reply via email to