[Soap-Python] rpclib: anydict as a parameter question

Dennis Fischer dfischer at key-systems.net
Thu May 31 09:35:37 CEST 2012


Hello,

I have question regarding soap server implementation using rpclib. I 
want to create a soap api with different methods. These methods should 
use a dict as a parameter to transfer different strings to the api. The 
server / client code are posted below. My problem is that, as seen in 
the [log] section, the variable 'params' in the [server] section is a 
WsgiMethodContext object, not the expected dict I want to use.

What am I doing wrong here? Can anyone post an example of how to pass a 
dict as a parameter using rpclib?

Thanks for your help :)

[Server]

# coding: utf-8

from rpclib.decorator import rpc
from rpclib.service import ServiceBase
from rpclib.model.primitive import AnyDict


class ApiInterface(ServiceBase):

     @rpc(AnyDict,_returns=AnyDict)
     def Ping(params):

        print("[PARAMS] " + str(params))
        return { 'result' : 1 }

[Client]

#! /usr/bin/python
# coding: utf-8

from suds.client import Client

api = Client('http://api.soaptest.com:1234/?wsdl', cache=None)

params = { }
params['user'] = [ 'abc' ]
result = api.service.Ping(params)
print(str(result))

[Result]

(anyType){
    result = "1"
  }

[Log]

[Thu May 31 09:02:03 2012] [error] [PARAMS] WsgiMethodContext(
[Thu May 31 09:02:03 2012] [error] \tfunction=<function Ping at 
0x7f9fa4d648c0>,
[Thu May 31 09:02:03 2012] [error] \tout_body_doc=None,
[Thu May 31 09:02:03 2012] [error] \tout_string=None,
[Thu May 31 09:02:03 2012] [error] \tlocale=None,
[Thu May 31 09:02:03 2012] [error] \tservice_class=<class 
'api.ApiInterface.ApiInterface'>,
[Thu May 31 09:02:03 2012] [error] \tapp=<rpclib.application.Application 
object at 0x7f9fa4d66bd0>,
[Thu May 31 09:02:03 2012] [error] \tout_header_doc=None,
[Thu May 31 09:02:03 2012] [error] \tcall_end=None,
[Thu May 31 09:02:03 2012] [error] \tout_object=None,
[Thu May 31 09:02:03 2012] [error] \tudc=None,
[Thu May 31 09:02:03 2012] [error] \tout_document=None,
[Thu May 31 09:02:03 2012] [error] \tout_header=None,
[Thu May 31 09:02:03 2012] [error] \tin_document=<Element 
{http://schemas.xmlsoap.org/soap/envelope/}Envelope at 0x7f9fa4d7bf00>,
[Thu May 31 09:02:03 2012] [error] \tin_error=None,
[Thu May 31 09:02:03 2012] [error] \tevent=<rpclib._base.EventContext 
object at 0x7f9fa4d6b050>,
[Thu May 31 09:02:03 2012] [error] 
\ttransport=<rpclib.server.wsgi.WsgiTransportContext object at 
0x7f9fa4d6b390>,
[Thu May 31 09:02:03 2012] [error] \tin_body_doc=<Element {dd24.api}Ping 
at 0x7f9fa4d7bf50>,
[Thu May 31 09:02:03 2012] [error] \tin_object=[],
[Thu May 31 09:02:03 2012] [error] 
\t_MethodContext__descriptor=<rpclib._base.MethodDescriptor object at 
0x7f9fa4d66410>,
[Thu May 31 09:02:03 2012] [error] \tcall_start=1338447723.4348221,
[Thu May 31 09:02:03 2012] [error] \tfrozen=True,
[Thu May 31 09:02:03 2012] [error] \tin_string=<generator object 
__wsgi_input_to_iterable at 0x7f9fa4d7b4b0>,
[Thu May 31 09:02:03 2012] [error] 
\tmethod_request_string='{dd24.api}Ping',
[Thu May 31 09:02:03 2012] [error] \tout_error=None,
[Thu May 31 09:02:03 2012] [error] \taux=None,
[Thu May 31 09:02:03 2012] [error] \tin_header_doc=None,
[Thu May 31 09:02:03 2012] [error] \tin_header=None,
[Thu May 31 09:02:03 2012] [error] ))




More information about the Soap mailing list