4.1.2 Calling Utility Methods Using SOAP and Java

Once the new OvmWsUtilitiesSoapClient has been created, the methods exposed through the Utilities SOAP API can be used in the same fashion as those exposed by the core SOAP API. The Java example source code provided in OvmWsUtilitiesSoapClient.java, in the SDK, provides excellent examples of how to access the methods exposed through the Utilities SOAP API. The truncated sample program listing, presented below, shows how the getAvailableEthernetPorts method is set up in the OvmWsUtilitiesSoapClient.

...
public class OvmWsUtilitiesSoapClient implements OvmWsUtilitiesClient
{
    private final OvmUtilities api;

    public OvmWsUtilitiesSoapClient(final OvmUtilities utilityApi)
    {
        this.api = utilityApi;
    }

    @SuppressWarnings("unchecked")
    @Override
    public BusinessSelection<EthernetPort> getAvailableEthernetPorts(final Id<Server> serverId, 
            final Id<Network> networkId)
        throws WsException
    {
        try
        {
            return api.getAvailableEthernetPorts(serverId, networkId);
        }
        catch (final WsException_Exception e)
        {
            throw convertException(e);
        }
    }
...
}