Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I output what SUDs is generating/receiving?

I have the following code:

from suds.client import Client import logging  logging.basicConfig(level=logging.INFO) logging.getLogger('suds.client').setLevel(logging.DEBUG) logging.getLogger('suds.transport').setLevel(logging.DEBUG) logging.getLogger('suds.xsd.schema').setLevel(logging.DEBUG) logging.getLogger('suds.wsdl').setLevel(logging.DEBUG)  SB_PRIVATE_ACCESS = {"PATH":"https://thisurl.com:443/services/",}  client = Client(SB_PRIVATE_ACCESS['PATH']) print client 

but I am getting 500 errors. I am trying to send what XML is being generated and received through SUDs, to the wsdl developer, but I can't figure how to output it? I have been looking in the documentation of SUDs, but can't seem to find it :/ Does anyone know how to output the raw xml that is sent and received?

like image 676
alfredo Avatar asked Dec 13 '10 06:12

alfredo


People also ask

What is suds in Python?

Install Suds Suds is a SOAP module for Python, which allows Python to consume wsdl files. Setuptools that you installed in the previous step includes an Easy Install program that you can use to install the correct version of suds. Download the suds egg from https://pypi.python.org/pypi/suds.

What is suds package?

GitHub - suds-community/suds: Suds is a lightweight SOAP python client for consuming Web Services. A community fork of the jurko fork.

What is suds object?

Suds is a lightweight library that uses SOAP based clients for python. SOAP is an RPC (Remote Procedure Call) that uses object-oriented protocol. Suds is actually lightweight SOAP python client that provides a service proxy for web services.


2 Answers

SUDS provides some convenience methods to do just that:

 client.last_sent()  client.last_received() 

These should provide you with what you need. I use them for error logging. The API doc for Client class should have any extra info you need.

like image 146
olly_uk Avatar answered Oct 02 '22 14:10

olly_uk


You can use the MessagePlugin to do this (this will work on the newer Jurko fork where last_sent and last_received have been removed)

from suds.plugin import MessagePlugin  class LogPlugin(MessagePlugin):   def sending(self, context):     print(str(context.envelope))   def received(self, context):     print(str(context.reply))  client = Client("http://localhost/wsdl.wsdl", plugins=[LogPlugin()]) 
like image 21
Damian Avatar answered Oct 02 '22 15:10

Damian