Hello,
I m trying out vsphere SDK 6.0 java samples for management API .
run.bat com.vmware.vsphere.samples.LoginByTokenSample https://<IP of vcenter>/sts/STSService/vsphere.local administrator@vsphere.local mypassword https://<IP vcenter>sdk
but connection to vcenter failed with following error. However I am able to log in to vcenter via web client using same credentials. Even I was able to login to VAPI endpoint that is vCloud suite endpoint service using vCloud suiteSDK 6.0 sample (TaggingWorkflow) but could not get to log in to vcenter.
Here is the ouput of LoginByTokenSample that I'm getting:
Acquiring a bearer token using the AcquireBearerTokenByUserCredentialSample sample
Token details:
AssertionId = _faf5786a-286b-43b0-b66e-4f26d833997d
Token type = Bearer
Issued On = 2017-11-15T09:23:48.077Z
Bearer Token received....
Connecting to the vCenter https://X.X.X.X/sdk....
Invoking the loginUsingSAMLToken method
Exception in thread "main" com.vmware.vim25.InvalidLoginFaultMsg: Cannot complete login due to an incorrect user name or password.
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at com.sun.xml.internal.ws.fault.SOAPFaultBuilder.createException(SOAPFaultBuilder.java:135)
at com.sun.xml.internal.ws.client.sei.StubHandler.readResponse(StubHandler.java:238)
at com.sun.xml.internal.ws.db.DatabindingImpl.deserializeResponse(DatabindingImpl.java:189)
at com.sun.xml.internal.ws.db.DatabindingImpl.deserializeResponse(DatabindingImpl.java:276)
at com.sun.xml.internal.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:104)
at com.sun.xml.internal.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:77)
at com.sun.xml.internal.ws.client.sei.SEIStub.invoke(SEIStub.java:147)
at com.sun.proxy.$Proxy46.loginByToken(Unknown Source)
at com.vmware.vsphere.samples.LoginByTokenSample.getSessionCookieUsingBearerToken(LoginByTokenSample.java:299)
at com.vmware.vsphere.samples.LoginByTokenSample.loginUsingSAMLToken(LoginByTokenSample.java:191)
at com.vmware.vsphere.samples.LoginByTokenSample.main(LoginByTokenSample.java:229)
Done.
Any help or how to debug this issue is greatly appreciated.
Hello,
We had the same problem. The solution is the version of the JRE you are using: for Java8, you need at least the update 172.
Chris
Update:
I tried running ValidateToken to check the validity of token and I got following error.
Exception in thread "main" com.sun.xml.internal.ws.fault.ServerSOAPFaultException: Client received SOAP Fault from server: The given assertion cannot be parsed. :: Error parsing SAML token. :: Error parsing SAML token. :: UndeclaredPrefix: Cannot resolve 'xs:string' as a QName: the prefix 'xs' is not declared. Please see the server log to find more detail regarding exact cause of the failure.
at com.sun.xml.internal.ws.fault.SOAP11Fault.getProtocolException(SOAP11Fault.java:178)
at com.sun.xml.internal.ws.fault.SOAPFaultBuilder.createException(SOAPFaultBuilder.java:116)
at com.sun.xml.internal.ws.client.sei.StubHandler.readResponse(StubHandler.java:238)
at com.sun.xml.internal.ws.db.DatabindingImpl.deserializeResponse(DatabindingImpl.java:189)
at com.sun.xml.internal.ws.db.DatabindingImpl.deserializeResponse(DatabindingImpl.java:276)
at com.sun.xml.internal.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:104)
at com.sun.xml.internal.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:77)
at com.sun.xml.internal.ws.client.sei.SEIStub.invoke(SEIStub.java:147)
at com.sun.proxy.$Proxy39.validate(Unknown Source)
at com.vmware.sso.client.samples.ValidateTokenSample.isTokenValid(ValidateTokenSample.java:136)
at com.vmware.sso.client.samples.ValidateTokenSample.main(ValidateTokenSample.java:184)
So it seems there is an issue with token itself but still figuring out what is the issue.
Update: I could log in to vcenter web service using by establishing a Session with Username and Password Credentials. But still getting error in
Hello,
We had the same problem. The solution is the version of the JRE you are using: for Java8, you need at least the update 172.
Chris
With Java 9, you should add a dependency on jaxws-rt:
<dependency>
<groupId>com.sun.xml.ws</groupId>
<artifactId>jaxws-rt</artifactId>
<version>2.2.9-b14002</version>
</dependency>
Version 2.2.9 of jaxws is the one used by the JDK 8.