torsdag den 30. september 2010

Developing a client for VMware vSphere Web Services SDK using Apache CXF


1. Generating the client code from the wsdl

The documentation for the WSDLToJava tool is available at the Apache CXF homepage.

org.apache.cxf.tools.wsdlto.WSDLToJava -p com.vmware.vim25 /home/<username>/SDK/wsdl/vim25/vimService.wsdl

2. Instantiate a client where you can call the operations

        JaxWsProxyFactoryBean proxyFactory = new JaxWsProxyFactoryBean();
        proxyFactory.setServiceClass(VimPortType.class);
        proxyFactory.setAddress(url);
        VimPortType vimPort = (VimPortType) proxyFactory.create();

3. Enable session management
Because of the way you login to the VMware vSphere Web Services it is necessary to maintain a session. To enable session management for the CXF client you need to add the following code.

        ((BindingProvider) vimPort).getRequestContext().put(BindingProvider.SESSION_MAINTAIN_PROPERTY, true);

4. The client should be able to follow redirects to support httpsWithRedirect
        Client client = ClientProxy.getClient(vimPort);

        HTTPConduit conduit = (HTTPConduit) client.getConduit();
        conduit.getClient().setAutoRedirect(true);

5. Get SSL to work
First run it so that it just trusts everybody.

        TrustManager[] simpleTrustManager = new TrustManager[] { new X509TrustManager() {
            public java.security.cert.X509Certificate[] getAcceptedIssuers() {
                return null;
            }

            public void checkClientTrusted(java.security.cert.X509Certificate[] certs, String authType) {
            }

            public void checkServerTrusted(java.security.cert.X509Certificate[] certs, String authType) {
            }
        } };
        TLSClientParameters tlsParams = new TLSClientParameters();
        tlsParams.setTrustManagers(simpleTrustManager);
        tlsParams.setDisableCNCheck(true);
        conduit.setTlsClientParameters(tlsParams);

Now we know the web service part works.
Replace the TrustManager with one that have access to the relevant keystore to be sure your keystore contains the right certificates:

        TLSClientParameters tlsParams = new TLSClientParameters();
        tlsParams.setTrustManagers(new TrustManager[] { getTrustManager() });
        tlsParams.setDisableCNCheck(true);
 

        conduit.setTlsClientParameters(tlsParams); 

That is it. Now a client for the vSphere web service SDK is ready and can start querying and manipulating a vSphere environment.

On this blog it is explained that one should include the all important cxf.xml. I haven't seen any need for that for this client.

torsdag den 9. september 2010

Getting Broadcom 43xx to work with openSUSE 11.3


It is very simple to get this to work.

If you want to make sure you have the right device you can run as root:

hostname:~ # lspci | grep BCM43
0c:00.0 Network controller: Broadcom Corporation BCM4311 802.11b/g WLAN (rev 01)
The outcome shows that my device is a BCM4311.

Here is what you have to run:
hostname:~ # suhostname:~ # install_bcm43xx_firmwarehostname:~ # init 6 <----to restart