VMware {code} Community
mzeb
Contributor
Contributor

Session not Authenticated

I'm trying to log in to ESXi 4.1 programatically but my platform doesn't support either the java or c# sdks so I'm building my own from soap to work against the web SDK. Currently I get two packets sent (RetrieveServiceContent and Login) with the second one failing claiming the session is not authenticated. My packet text is below (with the password omitted) taken directly from wireshark. Everything looks in order as far as this is concerned. I have noticed in a trace taken using the SDK there are a handful of packets that hit the HTTP server that aren't soap packets between the RetrieveServiceContent and the Login packets. Is there something in there I'm missing? Thanks.

<?xml version='1.0' encoding='UTF-8' ?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<ns1:Login xmlns:ns1=\"urn:vim25\">
<ns1:_this type=\"SessionManager\">
hs-sessionmgr
</ns1:_this>
<ns1:userName>
root
</ns1:userName>
<ns1:password>
-omitted-
</ns1:password>
</ns1:Login>
</soapenv:Body>
</soapenv:Envelope>
0 Kudos
2 Replies
Steve_Jin
Expert
Expert

Hi MZeb,

You can take a look at the open source VI Java API implementation, mostly the com.vmware.vim25.mo.ws package

http://vijava.svn.sourceforge.net/viewvc/vijava/trunk/src/com/vmware/vim25/ws/

In particular the WSClient.java will be very helpful for you.

On top of my head, one thing that might be missing is to capture the cookie from your first SOAP response and send it back in your second request.

Steve Jin (http://www.doublecloud.org)

Steve JIN Author of VMware VI and vSphere SDK; Creator of open source VI Java API (http://vijava.sf.net); Blogger at http://www.doublecloud.org
0 Kudos
mzeb
Contributor
Contributor

Yep, it was the cookie. Was so caught up in the soap XML didn't even think to check the http header. Thanks much, login going great now.

0 Kudos