During the Oracle Fusion Middleware Partner Community Forum in Budapest (March 2015), Luc Bors and myself are presenting a live demo with Luc developing a mobile application (using MAF) that consumes REST services that are published on my laptop from within a Virtual Box VM that runs Oracle SOA Suite.
Our challenge for this live demo was: how to make the services exposed in the VM available to Luc’s laptop?
Our solution – based on a valuable solution from my colleague Chris Gralike – involves the personal hotspot feature of our smart phone (to link up the laptops) together with Apache HTTP server to handle requests and forward them to the client (Virtual Box machine) that is not accessible directly from the outside.
Personal Hotspot
The personal hotspot is switched on, on a smart phone. Both laptops are connected through their Wireless Network Adapters to this hotspot. Both are awarded IP addresses. Only the IP address of the server laptop (the one with the REST services) is relevant. Using ipconfig on the command line we find out about this ip address.
Luc can ping my laptop using this IP address – the first good sign that we are in business.
Then, a very important step as it turned out , on my laptop I have to set the network type for the wireless connection to the personal hotspot. This type has to be set to Home network (or at least something less prohibitive than Public) in order for Luc’s HTTP requests to actually reach the Apache HTTP server.
Note: Luc could edit the hosts file on his laptop to associate a logical host name with the (current) IP address. When all this references are to that logical name rather than the IP address, he will have to make changes only in one location (the hosts file) when the IP address changes when we do our demo in a different setting.
Configure Apache HTTP to route into the VM
The REST services on the Virtual Box VM are accessible on my laptop through the Host Only Network Adapter configured on the VM. I could have changed this configuration into the Bridged Network Adapter that would make the VM a player in its own right on our little network. Instead, I decided to install Apache HTTP and have it route the requests from my laptop to the VM.
I used the XAMPP distribution that was easy to download and install.
I configured the HTTP server to listen to port 8080, by including this line in the apache httpd.conf file:
Listen 8080
This means that HTTP requests received by my laptop on port 8080 – from a browser running locally or from Luc’s laptop – are handled by the Apache server.
By also configuring the following reverse proxy rule – in the same configuration file:
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_http_module modules/mod_proxy_http.so
ProxyPass /FlyingHigh/ http://soa2admin2:8011/
ProxyPass /FlyingHighCustomer/ http://soa2admin2:8001/
ProxyPassreverse / http://localhost:8080/
I specified that requests for the URL segment /FlyingHigh have to be forwarded to the http://soa2admin2:8011/ which is the base address for the Service Bus managed server in my Virtual Box VM.
A request such as
http://<ip-adres van mijn laptop>:8080/FlyingHigh/FlyingHigh/FlightService/FlightService/flights/KL34?flightDate=2015-03-07 sent from Luc’s laptop is rerouted because of this rule to:
http://soa2admin2:8011/FlyingHigh/FlightService/FlightService/flights/KL34?flightDate=2015-03-07. In this example, my laptop’s ip address found on the command line is: 192.168.43.196.
Summary
In a few fairly simple steps – the personal hotspot that brings the two laptops together in a private network where they can access each other, configuring the network as Home (rather than Public), configuring Apache HTTP with a reverse proxy to route requests to the Virtual Box VM – we had our demo working. Let’s go rock.