chico201110141
Contributor
Contributor

soapUI: faultstring: The session is not authenticated

Leveraging the vSphere Web Services SDK via https://servername/sdk/vimService and authenticating with my creds...

I can submit a Login service call via SoapUI successfully:
<soapenv:Envelope xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<LoginResponse xmlns="urn:vim25">
<returnval>
<key>A44E83AA-8342-4C38-9037-C37C006BABC3</key>
<userName>redacted</userName>
<fullName>redacted</fullName>
<loginTime>2011-06-21T17:14:53.714939Z</loginTime>
<lastActiveTime>2011-06-21T17:14:53.714939Z</lastActiveTime>
<locale>en</locale>
<messageLocale>en</messageLocale>
</returnval>
</LoginResponse>
</soapenv:Body>
</soapenv:Envelope>

DateTue, 21 Jun 2011 19:35:29 GMT
#status#HTTP/1.1 200 OK
Content-Length677
Set-Cookievmware_soap_session="BD44857C-B359-4A7E-8E91-7993BE9AA9A1"; Path=/;
Content-Typetext/xml; charset=utf-8
ConnectionKeep-Alive
Cache-Controlno-cache

When I try to call FindByDNSName:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:vim25">
<soapenv:Header/>
<soapenv:Body>
<urn:FindByDnsName>
<urn:_this type="SearchIndex">SearchIndex</urn:_this>
<urn:dnsName>servername</urn:dnsName>
<urn:vmSearch>true</urn:vmSearch>
</urn:FindByDnsName>
</soapenv:Body>
</soapenv:Envelope>

Here is my response:
<soapenv:Envelope xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<soapenv:Fault>
<faultcode>ServerFaultCode</faultcode>
<faultstring>The session is not authenticated.</faultstring>
<detail>
<NotAuthenticatedFault xsi:type="NotAuthenticated" xmlns="urn:vim25">
<object type="Folder">group-d1</object>
<privilegeId>System.View</privilegeId>
</NotAuthenticatedFault>
</detail>
</soapenv:Fault>
</soapenv:Body>
</soapenv:Envelope>

It doesn't seem like I have to submit a "KEY" for these soap calls based on the documentation, but yet I get "The session is not authenticated". I am connecting to the same https url mentioned above and with my creds just the same as the Login method above.

I tried adding the header in soapUI and still get the same faultstring above

i.e. I get this back from the login soap call:

Set-Cookievmware_soap_session="BD44857C-B359-4A7E-8E91-7993BE9AA9A1"; Path=/;

So, in soapUI I add that to the FindByDnsName request. The response is "The session is not authenticated" with these headers

DateTue, 21 Jun 2011 19:40:24 GMT
#status#HTTP/1.1 500 Internal Server Error
Content-Length643
Set-Cookievmware_soap_session="145FE182-FCAB-4994-B1D3-FC9544BC4AD4"; Path=/;
Content-Typetext/xml; charset=utf-8
ConnectionKeep-Alive
Cache-Controlno-cache

So even though I submitted the vmware_soap_session the response came back with another sessionid...

So how do I format the proper soap call for FindByDnsName?

VMware vCenter Server 4.1.0 build-345043  /  apiVersion="4.1"

0 Kudos
6 Replies
Steve_Jin
Expert
Expert

Before calling FindByDNSName(), you MUST call one of the login methods in SessionManager, for example login(); otherwise how the server knows you have the permission to search. 🙂 For more details, you can check the ServiceInstance.java in the VI Java API: http://vijava.sf.net.

http://vijava.svn.sourceforge.net/viewvc/vijava/trunk/src/com/vmware/vim25/mo/ServiceInstance.java

Wish you good luck!

Steve Jin, author of VMware VI and vSphere SDK, 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
chico201110141
Contributor
Contributor

As you can see from my original post I am putting the vmware_soap_session in as an http cookie header and still getting the same faultcode/string. I even have tried adding set-cookie "xmlns="urn:vim25" to the http request as well...

Have you tried to use soapUI to simulate this successfully?

http://www.soapui.org/

Just point it at your wsdl and it will build the service calls.. https://servername/sdk/vimService.wsdl

Here is the Login service call example:

login.png

Here is the FindByDnsName example:

FindByDnsName.png

0 Kudos
chico201110141
Contributor
Contributor

Has anyone been able to simulate SOAP requests to the Web Services API as I am trying to do via soapUI?

0 Kudos
chico201110141
Contributor
Contributor

I figured out my issue. When sending the cookie do not use Set-Cookie as the header. Use Cookie and then the value of it like below.. doh!

vsphere soap request.png

0 Kudos
BenimusIQ
Contributor
Contributor

Hello, I think I am running into the same issue you did, can you post the full contents of your cookie please? I also note my session IDs are being returned by the server with lowercase letters (abcdef) instead of uppercase like yours, is this a change in vSphere 5 API do you know?

0 Kudos
chico201110141
Contributor
Contributor

The last screenshot I posted on the bottom left has the full contents of the cookie. That session id changes all the time, and unless you authenticate properly your session id won't be valid.

Here is another example of one:

Set-Cookievmware_soap_session="B9943CBC-096A-41F4-A680-17C545F6D324"; Path=/;

0 Kudos