Hello burak,
thanks for your help.
I have made these changes, but now i receive a new error. Do you have
any suggestions on this one:
[client]
suds raises the following exception:
Traceback (most recent call last):
File "./tests/api_test.py", line 84, in <module>
result = api.service.Ping(params)
File "/usr/lib/pymodules/python2.6/suds/client.py", line 539, in __call__
return client.invoke(args, kwargs)
File "/usr/lib/pymodules/python2.6/suds/client.py", line 598, in invoke
result = self.send(msg)
File "/usr/lib/pymodules/python2.6/suds/client.py", line 633, in send
result = self.failed(binding, e)
File "/usr/lib/pymodules/python2.6/suds/client.py", line 684, in failed
r, p = binding.get_fault(reply)
File "/usr/lib/pymodules/python2.6/suds/bindings/binding.py", line
238, in get_fault
raise WebFault(p, faultroot)
suds.WebFault: Server raised fault: 'Namespace prefix xs on user is not
defined, line 6, column 21'
[server]
The server debug log shows me the following:
[Thu May 31 10:12:03 2012] [error]
ERROR:rpclib.protocol.soap.soap11:<SOAP-ENV:Envelope
xmlns:ns0="dd24.api"
xmlns:ns1="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
[Thu May 31 10:12:03 2012] [error] <SOAP-ENV:Header/>
[Thu May 31 10:12:03 2012] [error] <ns1:Body>
[Thu May 31 10:12:03 2012] [error] <ns0:Ping>
[Thu May 31 10:12:03 2012] [error] <ns0:params>
[Thu May 31 10:12:03 2012] [error] <xs:user>abc</xs:user>
[Thu May 31 10:12:03 2012] [error] </ns0:params>
[Thu May 31 10:12:03 2012] [error] </ns0:Ping>
[Thu May 31 10:12:03 2012] [error] </ns1:Body>
[Thu May 31 10:12:03 2012] [error] </SOAP-ENV:Envelope>
Which leads to this result:
[Thu May 31 10:12:03 2012] [error]
DEBUG:rpclib.protocol.soap.soap11:\x1b[1;31mResponse\x1b[0m <?xml
version='1.0' encoding='ASCII'?>
[Thu May 31 10:12:03 2012] [error] <senv:Envelope
xmlns:wsa="http://schemas.xmlsoap.org/ws/2003/03/addressing"
xmlns:tns="dd24.api"
xmlns:plink="http://schemas.xmlsoap.org/ws/2003/05/partner-link/"
xmlns:xop="http://www.w3.org/2004/08/xop/include"
xmlns:senc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:s12env="http://www.w3.org/2003/05/soap-envelope/"
xmlns:s12enc="http://www.w3.org/2003/05/soap-encoding/"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:senv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/">
[Thu May 31 10:12:03 2012] [error] <senv:Body>
[Thu May 31 10:12:03 2012] [error] <senv:Fault>
[Thu May 31 10:12:03 2012] [error]
<faultcode>senv:Client.XMLSyntaxError</faultcode>
[Thu May 31 10:12:03 2012] [error] <faultstring>Namespace prefix xs on
user is not defined, line 6, column 21</faultstring>
[Thu May 31 10:12:03 2012] [error] <faultactor></faultactor>
[Thu May 31 10:12:03 2012] [error] </senv:Fault>
[Thu May 31 10:12:03 2012] [error] </senv:Body>
[Thu May 31 10:12:03 2012] [error] </senv:Envelope>
[Thu May 31 10:12:03 2012] [error]
If I use a String (for testing purpose) instead of a AnyDict, it works
like a charm
Am 31.05.2012 09:59, schrieb Burak Arslan:
Hi,
With @rpc, the first parameter is always the context object (ctx by
convention).
You should do either this:
@rpc(AnyDict,_returns=AnyDict)
def Ping(ctx, params):
or this:
@srpc(AnyDict,_returns=AnyDict)
def Ping(params):
best,
burak
On 31/05/12 10:35, Dennis Fischer wrote:
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] ))
_______________________________________________
Soap mailing list
[email protected]
http://mail.python.org/mailman/listinfo/soap
--
Bei weiteren Fragen stehen wir Ihnen gerne zur Verfügung.
Mit freundlichen Grüßen,
Dennis Fischer
Chief Development Officer - dd24
Key-Systems GmbH
Im Oberen Werk 1
66386 St. Ingbert
Tel.: +49 (0) 6894 - 9396 960
Fax.: +49 (0) 6894 - 9396 851
Email: [email protected]
Web: www.key-systems.net / www.RRPproxy.net
www.domaindiscount24.com / www.BrandShelter.com
Folgen Sie uns bei Twitter oder werden Sie unser Fan bei Facebook:
www.key-systems.net/facebook
www.twitter.com/key_systems
Geschäftsführer: Alexander Siffrin
Handelsregister Nr.: HR B 18835 - Saarbruecken
Umsatzsteuer ID.: DE211006534
Der Inhalt dieser Nachricht ist vertraulich und nur für den angegebenen
Empfänger bestimmt. Jede
Form der Kenntnisgabe, Veröffentlichung oder Weitergabe an Dritte durch den
Empfänger ist
unzulässig. Sollte diese Nachricht nicht für Sie bestimmt sein, so bitten wir
Sie, sich mit uns per
E-Mail oder telefonisch in Verbindung zu setzen.
--------------------------------------------
Should you have any further questions, please do not hesitate to contact us.
Best regards,
Dennis Fischer
Chief Development Officer - dd24
Key-Systems GmbH
Im Oberen Werk 1
DE-66386 St. Ingbert
Tel.: +49 (0) 6894 - 9396 960
Fax.: +49 (0) 6894 - 9396 851
Email: [email protected]
Web: www.key-systems.net / www.RRPproxy.net
www.domaindiscount24.com / www.BrandShelter.com
Follow us on Twitter or join our fan community on Facebook and stay updated:
www.key-systems.net/facebook
www.twitter.com/key_systems
CEO: Alexander Siffrin
Registration No.: HR B 18835 - Saarbruecken
V.A.T. ID.: DE211006534
Member of the KEYDRIVE GROUP
www.keydrive.lu
This e-mail and its attachments is intended only for the person to whom it is
addressed. Furthermore
it is not permitted to publish any content of this email. You must not use,
disclose, copy, print or
rely on this e-mail. If an addressing or transmission error has misdirected
this e-mail, kindly
notify the author by replying to this e-mail or contacting us by telephone.
_______________________________________________
Soap mailing list
[email protected]
http://mail.python.org/mailman/listinfo/soap