URL urlService = new URL("https://" +ComputerName + ":" + port + "/sdk/");
VimServiceLocator vimLocator = new VimServiceLocator();
vimLocator.setMaintainSession(true);
//Giving the Webservice to the locator to find it and verfy it
try{ vimService = vimLocator.getVimPort(urlService);
}catch (javax.xml.rpc.ServiceException se)
{
forkedaction.log("):Exception in getVimPort "+se);
throw new Exception("Exception in getVimPort "+se);
}
//Setting the Timeout to 24000
((org.apache.axis.client.Stub)vimService).setTimeout(I18Constant.TIMEOUT);
ManagedObjectReference vimServiceInstance = new ManagedObjectReference();
vimServiceInstance.setType("ServiceInstance");
vimServiceInstance.set_value("ServiceInstance");
/*Requires the following arguments:These have been mentioned in the XMl
-Daxis.socketSecureFactory=TimedOutSunFakeTrustSocketFactory
-Daxis.socketSecureFactory=org.apache.axis.components.net.SunFakeTrustSocketFactory
*/try{
vimServiceContent = vimService.retrieveServiceContent(vimServiceInstance);
}
catch(.content.vmware.vim.RuntimeFault rf)
{
forkedaction.log("Exception in retrieveServiceContent: "+rf);
throw new Exception("Exception in retrieveServiceContent :"+rf);
}
catch(java.rmi.RemoteException RE)
{
forkedaction.log(":Exception in retrieveServiceContent:RemoteException "+RE);
throw new Exception(":Exception in retrieveServiceContent :RemoteException"+RE);
}
When I am giving ip address as the value for the(ComputerName) in creating the URL retrieveServiceContent works fine but when I give FullhyQualified DNS name as the value for retrieveServiceContent I am getting a java.net.UnknownHostException thrown by (java.rmi.RemoteException RE)
Is it a constraint of retrieveServiceContent that only ipaddress should be used???
Thank you
Tejas Saner
Tejas,
Hostnames work perfectly well as part of the URL. The "UnknownHostException" means that either you've "fat-fingered" the hostname, or your DNS server is not configured properly. I've seen these types of anomolies when the system I'm working on has multiple NIC cards and the DNS server off one NIC does not know about the systems on the other NIC. If that occurs, then the DNS server from the first NIC responds with "UnknownHostException" for all hosts off the second NIC. IF this is the case, you can either change your DNS server... or stick to using IP addresses (its a network issue, not a VI SDK issue).
Tom
Tejas,
Hostnames work perfectly well as part of the URL. The "UnknownHostException" means that either you've "fat-fingered" the hostname, or your DNS server is not configured properly. I've seen these types of anomolies when the system I'm working on has multiple NIC cards and the DNS server off one NIC does not know about the systems on the other NIC. If that occurs, then the DNS server from the first NIC responds with "UnknownHostException" for all hosts off the second NIC. IF this is the case, you can either change your DNS server... or stick to using IP addresses (its a network issue, not a VI SDK issue).
Tom
Thanks a lot Tom for your quick response
Hi Tom,
I am still getting the error even after The DNS serer being configured properly and it doesnt seem to be a Network Issues.Can any other issue trigger such an Exception.
Thanks a lot for your help.Waiting eagerly for your reply
Tejas
Tejas,
It is a network error. That error is being returned from the network when attempting to resolve the hostname to an IP. Look at these areas:
Can you ping the host (using the same hostname) from your client?
Does ping resolve to an IP address? I'd be expecting no... which means your DNS is still broken or the hostname is not correct.
If yes, then is the IP the same one you were using previously?
Does your client system have multiple NIC cards? If yes, then assuming that they are on different subnets then you need 2 DNS servers. This typically happens when 1 NIC is "public" (like to the rest of your company) and the other is "private" (like into your datacenter).
For a different perspective, can the web browser see the MOB? https://YOUR-VC-OR-ESX/mob
Tom
VI Java API can make your code much less and easy to read. Your code can then be like:
ServiceInstance si = new ServiceInstance("https://" +ComputerName + ":" + port + "/sdk/", username, password, true);
ServiceContent sc = si.getServiceContent();
Steve JIN, VMware Engineering
HI Tom,
I tried all the steps which you had asked and all of them are working fine.
Can it be a issue since we are calling these api's from vm and not from a physical computer?
Thank you
Tejas Saner
Try:
nslookup <ComputerName>on the machine you are trying to make the VI "call"from. If this does not return a hostname, then there is a DNS issue somewhere which must be resolved.
This command works on windows and most unix like systems.
Check your dns server is correctly set:
nslookup
> server
Server: UnKnown
Address: 10.38.8.70 // ********** Check if this correct
>exit
Try a fully qualified computer name:
nslookup fish.chips.net instead of just:
nslookup fish
i