To use a Java service you have created and exposed in the vSphere Web Client service layer, a user interface plug-in module must import the service. You import the service by updating two metadata configuration files within your user interface plug-in module Web Archive (WAR) bundle.
Within your user interface plug-in module WAR bundle, locate the /war/src/main/webapp/META-INF/MANIFEST.MF file and add the following lines:
where com.vmware.myService is the name of the service package you have created.
Within the WAR bundle, locate the /war/src/main/webapp/WEB-INF/spring/bundle-context.xml file. This file specifies the necessary service parameters for the Flex-to-Java framework on the vSphere Web Client application server. Inside the
<beans> element of the
bundle-context.xml file, create the service references as follows:
The <flex: message broker > and
<flex:remoting-destination > elements declare your service as a destination for Flex remote object invocation.
Using a proxy class within your extension Flex component is the recommended way to manage communication between a custom Java service and your Flex data views. The vSphere Web Client includes a Flex utility library that includes a base proxy class. You can use this base proxy class to implement the proxy class that communicates with your service.
Example: Example ActionScript Proxy Class presents a sample ActionScript proxy class implementation. The sample proxy class extends the
com.vmware.flexutil.proxies.BaseProxy class provided by the vSphere Web Client.
You must set the Proxy constructor destination argument to the service ID that you have imported in your plug-in module configuration files. In
Example: Example ActionScript Proxy Class, the proxy constructor sets the
destination parameter to the service ID
myService, as defined in the WAR bundle configuration file (
/war/src/main/webapp/WEB-INF/spring/bundle-context.xml).
Within the proxy, you can call functions within the Java service by using the callService method. The
callService method is included in the package
com.vmware.flexutil.ServiceUtil. In
Example: Example ActionScript Proxy Class, the proxy class uses the
callService method to call the
echo method in the Java service.