I'm trying to use the Salesforce.com SOAP API. The login call returns
a session ID that should be set in the SOAP header of subsequent calls.
After much searching, I found an example of how to do this, but it
doesn't seem to work - I assume the soap4r api has changed since the
example was written.
Can anybody provide a short description of how this is done?
I know about ClientAuthHeaderHandler, but I can't figure out how it's
supposed to be used.
Regards, and thanks in advance for any help,
Ami.
-----
class ClientAuthHeaderHandler < SOAP::Header::SimpleHandler
MyHeaderName = XSD::QName.new("urn:partner.soap.sforce.com",
"sessionId")
attr_accessor :sessionid
def initialize
super(MyHeaderName)
@sessionid = nil
end
def on_simple_outbound
if @sessionid
{ "sessionid" => @sessionid }
end
end
def on_simple_inbound(my_header, mustunderstand)
@sessionid = my_header["sessionid"]
end
end
----
It still doesn't work (invalid session id), possibly because the
request should resemble this (from the Salesforce.com documentation):
<ns2:sessionId
xmlns:ns2="urn:enterprise.soap.sforce.com">uejMEgecf8yidA3zCjXlNKOSU</
ns2:sessionId>
but I'm producing this:
<sessionid>vWBLOmDK9MI6Xv9U4eTDteaH1xyGi1</sessionid>
I figure I have to use "XSD::QName.new" somewhere, but everywhere I've
tried gives incorrect results (and I obviously don't understand how
these classes are used).
Help?
... Ami.
There were a number of problems with the code I posted earlier,
including the case of off sessionId. I had figured those out, but I
still needed your little snippet to put the rest together. I'm using
the partner WSDL, although the example I had cut from the documentation
uses the enterprise WSDL. I think they're the same except the
enterprise WSDL is more strongly typed.
By the way, I had tried earlier to import the WSDL, but it I kept
getting errors (I can't remember exactly, something about nil values I
think). If you think this should work I can try again and post the
results.
Regards,
Ami.