Date Created: Thu 04-Aug-2011

Related Document Categories:



    Sample WebSphere 8 Application Client Connection Tester


    Assumes:

    com.ibm.ws.admin.client_8.0.0.jar is in the project's classpath
    that you have copied a sample soap.client.props file from the <was_instll_root>/<profile>/properties folder into c:/temp
    that you have copied the client keyrings to c:/temp for example
    /opt/IBM/WebSphere/AppServer/profiles/appsrv01/etc/DummyClientKeyFile.jks is copied to c:/temp
    /opt/IBM/WebSphere/AppServer/profiles/appsrv01/etc/DummyClientTrustFile.jks


    ============= Code ==============


    package com.screv;
    import java.util.Date;
    import java.util.Properties;
    import java.util.Set;

    import javax.management.InstanceNotFoundException;
    import javax.management.MalformedObjectNameException;
    import javax.management.Notification;
    import javax.management.NotificationListener;
    import javax.management.ObjectName;

    import com.ibm.websphere.management.AdminClient;
    import com.ibm.websphere.management.AdminClientFactory;
    import com.ibm.websphere.management.exception.ConnectorException;

    public class AdminClientConnection
    {
    private AdminClient adminClient;

    public static void main(String[] args)
    {
    AdminClientConnection aClient = new AdminClientConnection();

    // Create an AdminClient
    aClient.createAdminClient();

    }

    private void createAdminClient()
    {
    // Set up a Properties object for the JMX connector attributes
    Properties clientProps = new Properties();
    clientProps.setProperty(
    AdminClient.CONNECTOR_TYPE, AdminClient.CONNECTOR_TYPE_SOAP);
    clientProps.setProperty(AdminClient.CONNECTOR_HOST, "192.168.0.175");
    clientProps.setProperty(AdminClient.CONNECTOR_PORT, "8880");
    clientProps.setProperty(AdminClient.CONNECTOR_SECURITY_ENABLED, "true");
    clientProps.setProperty(AdminClient.USERNAME, "wasadmin");
    clientProps.setProperty(AdminClient.PASSWORD, "wasadmin");
    clientProps.setProperty(AdminClient.CONNECTOR_SOAP_CONFIG, "c:/temp/soap.client.props");
    clientProps.setProperty("javax.net.ssl.trustStore", "c:/temp/DummyClientTrustFile.jks");
    clientProps.setProperty("javax.net.ssl.keyStore", "c:/temp/DummyClientKeyFile.jks");
    clientProps.setProperty("javax.net.ssl.trustStorePassword", "WebAS");
    clientProps.setProperty("javax.net.ssl.keyStorePassword", "WebAS");

    // Get an AdminClient based on the connector properties
    try
    {
    adminClient = AdminClientFactory.createAdminClient(clientProps);
    }
    catch (ConnectorException e)
    {
    System.out.println("Exception creating Admin Client Connection: " + e);
    System.exit(-1);
    }

    System.out.println("Connected to Application Server");
    }

    }


Middleware Mentor - Steven Charles Robinson

About Me

Steve Robinson has been working in IT for over 15 years and has provided solutions for many large-enterprise corporate companies across the world. Steve specialises in Java and Middleware consulting. Steve comes from both an administration and development background.

Before moving to JEE, Steve was an accomplished developer and consultant for both IBM Lotus Notes and Microsoft .NET Technologies.

Follow Steve as @stevencrobinson on twitter.

Read my books?

IBM WebSphere Application Server 8.0 Administration Guide

IBM WebSphere Application Server 8.0 Administration Guide

WebSphere Application Server 7.0 Administration Guide

WebSphere Application Server 7.0 Administration Guide

WebSphere Categories

Oracle WebLogic Categories

JBoss Categories

Other Categories