can not remote connect to vboxwebsrv

Discussion about using the VirtualBox API, Tutorials, Samples.
Post Reply
Ghetas
Posts: 19
Joined: 19. Dec 2015, 17:35

can not remote connect to vboxwebsrv

Post by Ghetas »

Dear everyone
I am new on Virtualbox API. i have to connect to vboxwebsrv from remote pc on the same lan. i can connect to the service using web browser (FireFox) using url "http://10.207.165.23:18083/" but when i try to connect using the following code i got these error
the code

Code: Select all

import javax.xml.ws.BindingProvider;

import org.virtualbox_5_0.IVirtualBox;
import org.virtualbox_5_0.IWebsessionManager;
import org.virtualbox_5_0.jaxws.VboxPortType;
import org.virtualbox_5_0.jaxws.VboxService;



public class VirtualBoxConnector {

	private static VboxPortType port;
	
	
	
    public static void main(String[] args)
    {
    	IVirtualBox vbox=connect("http://10.207.165.23:18083/");
    	System.out.println(vbox.getVersion());
    }


	private static VboxPortType getPortType(String url) {
		if (null == port) {
			VboxService svc = new VboxService();
			port = svc.getVboxServicePort();
			((BindingProvider) port).getRequestContext().put(
					BindingProvider.ENDPOINT_ADDRESS_PROPERTY,
					url);
		}

		return port;
	}

	public static IVirtualBox connect(String url) {
		IWebsessionManager iWebsessionManager = new IWebsessionManager(url,getPortType(url));
		return iWebsessionManager.logon("", "");
	}
}
when i run my code i get the following error

Code: Select all

Exception in thread "main" javax.xml.ws.WebServiceException: Failed to access the WSDL at: file:/home/vbox/tinderbox/5.0-sdk/out/linux.amd64/release/obj/webservice/vboxwebService.wsdl. It failed with: 
	Got /home/vbox/tinderbox/5.0-sdk/out/linux.amd64/release/obj/webservice/vboxwebService.wsdl (No such file or directory) while opening stream from file:/home/vbox/tinderbox/5.0-sdk/out/linux.amd64/release/obj/webservice/vboxwebService.wsdl.
	at com.sun.xml.internal.ws.wsdl.parser.RuntimeWSDLParser.tryWithMex(RuntimeWSDLParser.java:173)
	at com.sun.xml.internal.ws.wsdl.parser.RuntimeWSDLParser.parse(RuntimeWSDLParser.java:155)
	at com.sun.xml.internal.ws.wsdl.parser.RuntimeWSDLParser.parse(RuntimeWSDLParser.java:120)
	at com.sun.xml.internal.ws.client.WSServiceDelegate.parseWSDL(WSServiceDelegate.java:258)
	at com.sun.xml.internal.ws.client.WSServiceDelegate.<init>(WSServiceDelegate.java:221)
	at com.sun.xml.internal.ws.client.WSServiceDelegate.<init>(WSServiceDelegate.java:169)
	at com.sun.xml.internal.ws.spi.ProviderImpl.createServiceDelegate(ProviderImpl.java:101)
	at javax.xml.ws.Service.<init>(Service.java:77)
	at org.virtualbox_5_0.jaxws.VboxService.<init>(VboxService.java:46)
	at Vmtest.TestVBox2.getPortType(TestVBox2.java:538)
	at Vmtest.TestVBox2.main(TestVBox2.java:290)
Caused by: java.io.IOException: Got /home/vbox/tinderbox/5.0-sdk/out/linux.amd64/release/obj/webservice/vboxwebService.wsdl (No such file or directory) while opening stream from file:/home/vbox/tinderbox/5.0-sdk/out/linux.amd64/release/obj/webservice/vboxwebService.wsdl
	at com.sun.xml.internal.ws.wsdl.parser.RuntimeWSDLParser.createReader(RuntimeWSDLParser.java:842)
	at com.sun.xml.internal.ws.wsdl.parser.RuntimeWSDLParser.resolveWSDL(RuntimeWSDLParser.java:283)
	at com.sun.xml.internal.ws.wsdl.parser.RuntimeWSDLParser.parse(RuntimeWSDLParser.java:140)
	... 9 more
Caused by: java.io.FileNotFoundException: /home/vbox/tinderbox/5.0-sdk/out/linux.amd64/release/obj/webservice/vboxwebService.wsdl (No such file or directory)
	at java.io.FileInputStream.open(Native Method)
	at java.io.FileInputStream.<init>(FileInputStream.java:146)
	at java.io.FileInputStream.<init>(FileInputStream.java:101)
	at sun.net.www.protocol.file.FileURLConnection.connect(FileURLConnection.java:90)
	at sun.net.www.protocol.file.FileURLConnection.getInputStream(FileURLConnection.java:188)
	at java.net.URL.openStream(URL.java:1037)
	at com.sun.xml.internal.ws.wsdl.parser.RuntimeWSDLParser.createReader(RuntimeWSDLParser.java:827)
	... 11 more
[Ghetas@GhetasLab1 VboxTesting]$ javac -cp src:./jar/vboxjws.jar -d classes ./src/Vmtest/VirtualBoxConnector.java
[Ghetas@GhetasLab1 VboxTesting]$ java -cp classes:./jar/vboxjws.jar Vmtest.VirtualBoxConnector
Exception in thread "main" javax.xml.ws.WebServiceException: Failed to access the WSDL at: file:/home/vbox/tinderbox/5.0-sdk/out/linux.amd64/release/obj/webservice/vboxwebService.wsdl. It failed with: 
	Got /home/vbox/tinderbox/5.0-sdk/out/linux.amd64/release/obj/webservice/vboxwebService.wsdl (No such file or directory) while opening stream from file:/home/vbox/tinderbox/5.0-sdk/out/linux.amd64/release/obj/webservice/vboxwebService.wsdl.
	at com.sun.xml.internal.ws.wsdl.parser.RuntimeWSDLParser.tryWithMex(RuntimeWSDLParser.java:173)
	at com.sun.xml.internal.ws.wsdl.parser.RuntimeWSDLParser.parse(RuntimeWSDLParser.java:155)
	at com.sun.xml.internal.ws.wsdl.parser.RuntimeWSDLParser.parse(RuntimeWSDLParser.java:120)
	at com.sun.xml.internal.ws.client.WSServiceDelegate.parseWSDL(WSServiceDelegate.java:258)
	at com.sun.xml.internal.ws.client.WSServiceDelegate.<init>(WSServiceDelegate.java:221)
	at com.sun.xml.internal.ws.client.WSServiceDelegate.<init>(WSServiceDelegate.java:169)
	at com.sun.xml.internal.ws.spi.ProviderImpl.createServiceDelegate(ProviderImpl.java:101)
	at javax.xml.ws.Service.<init>(Service.java:77)
	at org.virtualbox_5_0.jaxws.VboxService.<init>(VboxService.java:46)
	at Vmtest.VirtualBoxConnector.getPortType(VirtualBoxConnector.java:38)
	at Vmtest.VirtualBoxConnector.connect(VirtualBoxConnector.java:49)
	at Vmtest.VirtualBoxConnector.main(VirtualBoxConnector.java:20)
Caused by: java.io.IOException: Got /home/vbox/tinderbox/5.0-sdk/out/linux.amd64/release/obj/webservice/vboxwebService.wsdl (No such file or directory) while opening stream from file:/home/vbox/tinderbox/5.0-sdk/out/linux.amd64/release/obj/webservice/vboxwebService.wsdl
	at com.sun.xml.internal.ws.wsdl.parser.RuntimeWSDLParser.createReader(RuntimeWSDLParser.java:842)
	at com.sun.xml.internal.ws.wsdl.parser.RuntimeWSDLParser.resolveWSDL(RuntimeWSDLParser.java:283)
	at com.sun.xml.internal.ws.wsdl.parser.RuntimeWSDLParser.parse(RuntimeWSDLParser.java:140)
	... 10 more
Caused by: java.io.FileNotFoundException: /home/vbox/tinderbox/5.0-sdk/out/linux.amd64/release/obj/webservice/vboxwebService.wsdl (No such file or directory)
	at java.io.FileInputStream.open(Native Method)
	at java.io.FileInputStream.<init>(FileInputStream.java:146)
	at java.io.FileInputStream.<init>(FileInputStream.java:101)
	at sun.net.www.protocol.file.FileURLConnection.connect(FileURLConnection.java:90)
	at sun.net.www.protocol.file.FileURLConnection.getInputStream(FileURLConnection.java:188)
	at java.net.URL.openStream(URL.java:1037)
	at com.sun.xml.internal.ws.wsdl.parser.RuntimeWSDLParser.createReader(RuntimeWSDLParser.java:827)
	... 12 more
I am using
OS: Centos 6.7
VirtualBox 5.0.12
Language Java, jdk1.7

Thanks
noteirak
Site Moderator
Posts: 5229
Joined: 13. Jan 2012, 11:14
Primary OS: Debian other
VBox Version: OSE Debian
Guest OSses: Debian, Win 2k8, Win 7
Contact:

Re: can not remote connect to vboxwebsrv

Post by noteirak »

Your issue is that you don't use the API properly. You're trying to use internals objects.
The way you connect to the API via the webservice is as simple as this :

Code: Select all

VirtualBoxManager vboxManager = VirtualBoxManager.createInstance(null);
vboxManager.connect("http://yourhost:18083", "user", "password");
This is described at and in the SDK Reference PDF at page 386 (link is for 5.0.12)
Check the different sample codes for a fully working code with disconnect and cleanup management
Hyperbox - Virtual Infrastructure Manager - https://apps.kamax.lu/hyperbox/
Manage your VirtualBox infrastructure the free way!
Ghetas
Posts: 19
Joined: 19. Dec 2015, 17:35

Re: can not remote connect to vboxwebsrv

Post by Ghetas »

Thanks noteirak

this is work with me
noteirak wrote:Your issue is that you don't use the API properly. You're trying to use internals objects.
The way you connect to the API via the webservice is as simple as this :

Code: Select all

VirtualBoxManager vboxManager = VirtualBoxManager.createInstance(null);
vboxManager.connect("http://yourhost:18083", "user", "password");
This is described at and in the SDK Reference PDF at page 386 (link is for 5.0.12)
Check the different sample codes for a fully working code with disconnect and cleanup management
Post Reply