title: Sage CRM web services example in Python
body: <p>I am trying to write a Python consumer for Sage CRM using their Web Services interface. I am using SOAPpy as Python SOAP library (not married to it, was easy to install on Ubuntu so went with it). </p>
  
  <p>Managed to fetch the WSDL using the Proxy and executed the logon method exposed by Sage CRM. </p>
  
  <pre><code>
  from SOAPpy import *
  proxy = WSDL.Proxy('http://192.168.0.3/MATE/eware.dll/webservice/webservice.wsdl')
  </code></pre>
  
  <p>It returns a session object which sort of looks like</p>
  
  <pre>
  SOAPpy.Types.structType result at 151924492: {'sessionid': '170911104429792'}
  </pre>
  
  <p>Now I am trying to use Sage CRM's queryrecord method to query the data, and that returns </p>
  
  <pre>
  Fault SOAP-ENV:Server: No active usersession detected
  </pre>
  
  <p>Reading the documentation reveals that I have to send back to the session id that recd. when I logged in back with each requests.</p>
  
  <p>According to the Sage documentation I have to send it back as such</p>
  
  <pre><code>
  SID = binding.logon("admin", ""); 
  binding.SessionHeaderValue = new SessionHeader(); 
  binding.SessionHeaderValue.sessionId = SID.sessionid;
  </code>
  </pre>
  
  <p>Any ideas how to do append this to the headers using SOAPpy?</p>
  
  <p>Any pointers will be greatly appreciated.</p>