How can I infer which SUDs generate / receive?

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 get 500 errors. I am trying to send that XML is generated and received through SUD, to the wsdl developer, but I cannot figure out how to output it? I looked in the SUD documentation but can't find it: / Does anyone know how to output the raw XML address that is sent and received?

+44
python soap xml suds
Dec 13 '10 at 6:03
source share
6 answers

SUDS provides some convenient methods for this:

  client.last_sent() client.last_received() 

They should provide you with what you need. I use them to report errors. The doc API for the Client class should have any additional information that you need.

+66
May 20 '11 at 7:59
source share

You can use MessagePlugin to do this (this will work on the new Jurko fork where last_sent and last_received were deleted)

 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()]) 
+17
Jun 05 '14 at 15:53
source share

Suds supports internal registration, as you did.

I set information levels like you:

 logging.getLogger('suds.client').setLevel(logging.DEBUG) logging.getLogger('suds.transport').setLevel(logging.DEBUG) # MUST BE THIS? logging.getLogger('suds.xsd.schema').setLevel(logging.DEBUG) logging.getLogger('suds.wsdl').setLevel(logging.DEBUG) logging.getLogger('suds.resolver').setLevel(logging.DEBUG) logging.getLogger('suds.xsd.query').setLevel(logging.DEBUG) logging.getLogger('suds.xsd.basic').setLevel(logging.DEBUG) logging.getLogger('suds.binding.marshaller').setLevel(logging.DEBUG) 

And sometimes I also need to redefine the level of root logging, depending on the structure used under Suds calls (Django, Plone). If the root logger has a higher logging threshold, message logs may never appear (you don't know how log hierarchies should go). The following is an example of an override:

 def enableDebugLog(self): """ Enable context.plone_log() output from Python scripts """ import sys, logging logger = logging.getLogger() logger.root.setLevel(logging.DEBUG) logger.root.addHandler(logging.StreamHandler(sys.stdout)) 
+13
May 17 '11 at 17:39
source share

To get only the generated message, this also works:

 from suds.client import Client import sys SB_PRIVATE_ACCESS = {"PATH":"https://thisurl.com:443/services/",} client = Client(SB_PRIVATE_ACCESS['PATH']) client.set_options(nosend=True) resp = ...<invoke client here>... sys.stdout.buffer.write(resp.envelope) 
+6
Jan 12 '14 at 18:41
source share

try to change

 logging.basicConfig(level=logging.INFO) 

to

 logging.basicConfig(filename="/tmp/suds.log", level=logging.DEBUG) 
+2
Jun 08 2018-11-06T15
source share

If you want to reduce registration with jurko-suds

  logging.basicConfig(level=logging.INFO) logging.getLogger('suds.client').setLevel(logging.INFO) logging.getLogger('suds.transport').setLevel(logging.INFO) logging.getLogger('suds.xsd.schema').setLevel(logging.INFO) logging.getLogger('suds.wsdl').setLevel(logging.INFO) logging.getLogger('suds.resolver').setLevel(logging.INFO) logging.getLogger('suds.xsd.query').setLevel(logging.INFO) logging.getLogger('suds.xsd.sxbasic').setLevel(logging.INFO) logging.getLogger('suds.xsd.sxbase').setLevel(logging.INFO) logging.getLogger('suds.metrics').setLevel(logging.INFO) logging.getLogger('suds.binding.marshaller').setLevel(logging.INFO) 
0
Jan 08 '16 at 6:29
source share



All Articles