Forum Discussion
How do I use sessions in Icontrol API using java.
How do I use sessions in Icontrol API using java.
I have got the iControl Interface object. Then from the interface object I am getting the session object.
Now My question is How do I make sure that this is the very same session I am using when issuing create api calls throw iCOntrol SDK.
iCtrlInterface = IControlInterface.getIControlInterface(ipAddress, port, username, password);
iSession = iCtrlIntf.getSystemSession();
now i want to make use of this session object to make other calls through API so that I am in the same session.
Thanks
Kumar
2 Replies
- Kumar_107292
Nimbostratus
Posted By Kumar on 02/19/2013 08:09 AMHow do I use sessions in Icontrol API using java.
I have got the iControl Interface object. Then from the interface object I am getting the session object.
Now My question is How do I make sure that this is the very same session I am using when issuing create api calls throw iCOntrol SDK.
iCtrlInterface = IControlInterface.getIControlInterface(ipAddress, port, username, password);
iSession = iCtrlIntf.getSystemSession();
now i want to make use of this session object to make other calls through API so that I am in the same session.
Thanks
Kumar
going through various documents what I realized is that i can send session Id as a SOAP header element.But how? Pls Help on How to send the header element with my iControl Api call. I am using Java.
- Ryan_Lamore_804
Nimbostratus
Did you figure this out? I thought it was as simple as setting the session header, but it took me forever to get this to work. The tricky part was finding the right namespace. See the code below:
-----
SystemSessionBindingStub systemSessionStub1 = new Interfaces(config.host11(), config.user(), config.password()).getSystemSession();
Long sessionId1 = systemSessionStub1.get_session_identifier();
systemSessionStub1.setHeader("urn:iControl", "session", sessionId1.toString());
systemSessionStub1.set_session_timeout(300);
systemSessionStub1.set_active_folder("/Common");
SystemSessionBindingStub systemSessionStub2 = new Interfaces(config.host11(), config.user(), config.password()).getSystemSession();
Long sessionId2 = systemSessionStub2.get_session_identifier();
systemSessionStub2.setHeader("urn:iControl", "session", sessionId2.toString());
systemSessionStub2.set_session_timeout(300);
systemSessionStub2.set_active_folder("/Common");
systemSessionStub1.start_transaction();
try {
systemSessionStub2.start_transaction();
logger.debug("Opened two transactions!");
systemSessionStub2.rollback_transaction();
} catch (Exception e) {
Assert.fail("Couldn't create two transactions at the same time.", e);
} finally {
systemSessionStub1.rollback_transaction();
}
-----Hopefully this saves someone the wasted time trying to debug this. Perhaps we should move this code near the API documentation?
Ryan
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)Recent Discussions
Related Content
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com