Ping pong between server and client

I worked with Salesforce in recent period. A nice feature of this application is the possibility to send requests via the http protocol. Doing so, one may add data to this system.

How does it work? Generally speaking, one sends a signal to the system, upon which the system reacts. In my case, data are added to the system. The system also sends a signal in return. This signal may reveal whether the data are correctly added to the system.

The full code can be found here . and here

The idea is a python programme is written that send requests. The signals that are returned are interpreted within this programme. Elements from the signals are stored as variables. This allows to create a sequence of requests and answers. Let us follow the programme logic.

Step1: Send the UID and PSW with this request: req = urllib.request.Request(url, data, headers). This returns a sessionId. This sessionId acts as key for further work.

Step2: Access a particular object with the sessionId that we just acquired. The sessionId is stored in the header, whereas the object is stored in the data. The request looks as: urllib.request.Request(url, data, headers). This returns a jobId that can be used in further work.

Step3: Add the data to the object. The jobId is stored in the header; the actual data that will be added are stored in the data within the request. The request looks as: urllib.request.Request(url, data, headers). This returns a batchId. This batchId can be used later to check if the job went according to the wishes.

Step4: Close the job with urllib.request.Request(url, data, headers) with the sessionId in the header and the command close_job in the data.

Step5: allows to check the outcome of the batch with urllib.request.Request(url,headers= headers) with the batchid in the header.

Each time, a signal is returned. Quite often, an XML is returned. I investigated this XML as a string whereby I checked on the occurrence of a particular tag. I knew between a tag and end tag an element can be found that can be retrieved.

Door tom