kartagis / pysimplesoap

Automatically exported from code.google.com/p/pysimplesoap
0 stars 0 forks source link

Client should provide way of manipulating request XML before it is sent. #26

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
For my use with the client, I need to modify the XML request before it is sent 
out to the SOAP server.

Just before the XML is sent, the client code does this:
  self.xml_request = request.as_xml()

I currently subclass the client, override __setattr__ to catch the xml_request 
assignment, instantiate a SimpleXMLElement instance with the XML, and 
manipulate it that way.

I think the client should call a method with the XML object just before it 
turns it into a string to allow subclasses to manipulate it. For example:

 self.pre_send_xml_request(request)
 self.xml_request = request.as_xml()

where pre_send_xml_request is a method to be overridden by subclasses who want 
to manipulate the XML before it is sent.

Original issue reported on code.google.com by allan.cr...@yougov.com on 6 May 2011 at 3:20

GoogleCodeExporter commented 8 years ago
This sounds good, but I don't fully understand how subclasing will work.
I would like something easier, like preparsing and validating the xml_request 
before remote call itself, like the raw api.

i.e:

raw_request = client.prepare_wsdl_request(*args, **kwargs)
raw_request('sometag').add_child('spam', 'ham ham ham ham')
raw_response = client.raw_wsdl_call(method, raw_request)

Original comment by reingart@gmail.com on 10 May 2011 at 9:48

GoogleCodeExporter commented 8 years ago
I refer to using a subclass because I have a class which extends the current 
client which contains all the hacks that I need. I want to move all that 
functionality in PySimplesoap's client instead.

I'll see if I can change the implementation as you suggested. I'm currently 
using the "call" method of the client class (rather than "wdsl_call") - what 
would you like the method names to be? How about something like:
  - client.prepare_request(method, *args, **kwargs)
  - client.send_prepared_request(method, request)

Then the existing "call" method will use these two methods.

Original comment by allan.cr...@yougov.com on 11 Jan 2012 at 4:24