[XML-SIG] Problem using xmlrpclib.
M.-A. Lemburg
mal at lemburg.com
Wed Aug 6 23:52:24 EDT 2003
Brendan Rankin wrote:
> Hello,
>
> I am a complete newbie to xmlrpc and am trying to implement the client side
> access to a SalesForce.com server. They supply both an XMLRPC and a SOAP
> API. They have a two step authentication process to get logged in, which
> goes like this:
>
> 1. Login using "https://www.salesforce.com/servlet/servlet.Api".
> - This returns the following XML fields:
> 'userID':'<unique user ID>'
> 'server_url': '<server to use for API transactions>'
> 'session_id' : '<unique session ID>'
> - It also returns two "Set-Cookie" fields in the HTML headers (example
> shown below, not a "real" session_id):
> header: Set-Cookie: sfdcweb=65.213.42.132.194511060194978591; path=/;
> max-age=31536000
> header: Set-Cookie: sid=<ridiculously long session_id string>; path=/
>
> 2. The next step is to take 'session_id' and 'userID' and pass it along to
> the server specified by 'server_url', along with whatever API command you'd
> like to accomplish.
>
> I, successfully, receive the login Response, but when I send the next API
> Request, I consistently get the following error:
> -----------------------
> send: 'POST /servlet/servlet.Api HTTP/1.0\r\nHost:
> na1-api.salesforce.com\r\nUser-Agent: xmlrpclib.py/1.0.1 (by
> www.pythonware.com)\r\nContent-Type: text/xml\r\nContent-Length:
> 522\r\n\r\n'
> send: "<?xml version='1.0'
> encoding='UTF-8'?>\n<methodCall>\n<methodName>sfdc.get_server_timestamp</met
> hodName>\n<params>\n<param>\n<value><struct>\n<member>\n<name>version</name>
> \n<value><string>2.0</string></value>\n</member>\n<member>\n<name>userID</na
> me>\n<value><string>00530000000c4BV</string></value>\n</member>\n<member>\n<
> name>session_id</name>\n<value><string>vwxw8sPENpaDeLJgAQHt32W.W3A.eUH_B.hfo
> F8sylY9DjH7G27.Am2.dNnSI8zQWR1EFY6Muc1Dg9jOlW0BT.btzKggVlhL</string></value>
> \n</member>\n</struct></value>\n</param>\n</params>\n</methodCall>\n"
> reply: 'HTTP/1.0 200 OK\r\n'
> header: Server: Resin/2.1.9
> header: Content-Type: text/xml; charset=UTF-8
> header: Date: Wed, 06 Aug 2003 18:36:19 GMT
> body: '<?xml version="1.0" encoding="UTF-8"
> ?><methodResponse><fault><value><struct><member><name>faultString</name><val
> ue>session ID missing or
> invalid</value></member><member><name>faultCode</name><value><int>1112</int>
> </value></member></struct></value></fault></methodResponse>'
> Traceback (most recent call last):
> File "./bin/Python/sforceXMLRPC.py", line 56, in ?
> transactionServer.sfdc.get_server_timestamp( timestampParams )
> File "/usr/lib/python2.3/xmlrpclib.py", line 1029, in __call__
> return self.__send(self.__name, args)
> File "/usr/lib/python2.3/xmlrpclib.py", line 1316, in __request
> verbose=self.__verbose
> File "/usr/lib/python2.3/xmlrpclib.py", line 1080, in request
> return self._parse_response(h.getfile(), sock)
> File "/usr/lib/python2.3/xmlrpclib.py", line 1219, in _parse_response
> return u.close()
> File "/usr/lib/python2.3/xmlrpclib.py", line 742, in close
> raise Fault(**self._stack[0])
> xmlrpclib.Fault: <Fault 1112: 'session ID missing or invalid'>
> ------------------------
>
> I can attribute this problem to two possible issues:
>
> 1. Some sort of strange type-mismatch with what SalesForce.com is expecting
> to see in the session_id field.
> - Could also be an improperly set field for session_id.
> 2. My request does not contain the Cookie fields in the HTML headers.
I suppose it's problem 2 that's causing the error. xmlrpclib
doesn't magically do cookie by itself; you have to add support
for that to your application layer.
> Does anyone out there have any further suggestions? Any help would be
> greatly appreciated!
>
> Thank you and Best Regards,
>
> - Brendan
>
>
> _______________________________________________
> XML-SIG maillist - XML-SIG at python.org
> http://mail.python.org/mailman/listinfo/xml-sig
--
Marc-Andre Lemburg
eGenix.com
Professional Python Software directly from the Source (#1, Aug 06 2003)
>>> Python/Zope Products & Consulting ... http://www.egenix.com/
>>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/
________________________________________________________________________
More information about the XML-SIG
mailing list