I want to control virtualbox throuth webservice .On the sdk document(4.1.8 ), they use wsdl2java of axis2 1.4 to generate codes according the .wsdl files. In the example clienttest.java, there is a sentence "the classes VboxServiceLocator and VboxPortType have been created by the WSDL2Java helper". But i cann't get the two classes , no matter i use axis2 1.4 or axis2 1.4.1 or axis2 1.6. My host is windows7 64 bits, the version of virtualbox is 4.1.8. i use the command, "%axis2_home%\bin\wsdl2java -uri somepath\vboxwebservice.wsdl -u -p client -s -o stub", to generate java codes. The codes are available, but thay are redundant. for example, in order to get the version of the virtualbox, the code in clienttest.java is :
VboxService _service = new VboxServiceLocator();
VboxPortType _port = _service.getvboxServicePort();
String _oVbox = _port.IWebsessionManager_logon("", "");
String version = _port.IVirtualBox_getVersion(_oVbox);
but i need to write a lot of codes:
VboxServiceStub m_stub = new VboxServiceStub();
IWebsessionManager_logon logon = new IWebsessionManager_logon();
logon.setName("");
logon.setPassword("");
String _oVbox = m_stub.IWebsessionManager_logon(logon).getReturnval();
IVirtualBox_getVersion getVersion = new IVirtualBox_getVersion();
getVersion.set_this(_oVbox);
String version = m_stub.IVirtualBox-getVersion(getVersion).getReturnval();
where i did wrongly ? how i use the wsdl2java.bat so that i can get the java code like the clienttest.java says.
One more question
public String[] showVMs(){
String [] names = null;
String [] strMachines = null;
try{
IVirtualBox_getMachines getMachines = new IVirtualBox_getMachines();
getMachines.set_this(m_strVbox);
strMachines = m_stub.IVirtualBox_getMachines(getMachines).getReturnval();//the strMachines is not null, there is a string like b99553187a828b04-000000000000000f
for (int i = 0; i < strMachines.length;++i){
IMachine_getName getName = new IMachine_getName();
getName.set_this(strMachines);
names = m_stub.IMachine_getName(getName).getReturnval();//here would cause a java.lang.NullPointerException,the mothed IMachine_getName return null, but in the virtualbox i have a guest (windowsxp).
IManagedObjectRef_release release = new IManagedObjectRef_release();
release.set_this(m_strVbox);
m_stub.IManagedObjectRef_release(release);
}
}catch (Exception e){
e.printStackTrace();
}
return names;
}
i want to get the names of the guest machines, but the code doesn't work. why?
thank you for reading this. Can you help me?