Thursday, June 4, 2009

WebSphere 6.1 - JMX SOAP Connection Example

import java.util.Properties;
import com.ibm.websphere.management.AdminClient;
import com.ibm.websphere.management.AdminClientFactory;

public class JMXTest {

public static void main(String[] args) {
JMXTest jmxtest = new JMXTest();
jmxtest.execute();
}

public void execute() {
try {
Properties connectProps = new Properties(); 
connectProps.setProperty(AdminClient.CONNECTOR_TYPE, AdminClient.CONNECTOR_TYPE_SOAP); 
connectProps.setProperty(AdminClient.CONNECTOR_HOST, "{hostname}"); 
connectProps.setProperty(AdminClient.CONNECTOR_PORT, "{8879 or your-soap-port"); 
connectProps.setProperty(AdminClient.CONNECTOR_SECURITY_ENABLED, "true");
connectProps.setProperty(AdminClient.USERNAME, "{username}");
connectProps.setProperty(AdminClient.PASSWORD, "{password}");
connectProps.setProperty("javax.net.ssl.trustStore", "/opt/IBM/WebSphere/AppServer/profiles/Dmgr01/etc/DummyClientTrustFile.jks");
connectProps.setProperty("javax.net.ssl.keyStore", "/opt/IBM/WebSphere/AppServer/profiles/Dmgr01/etc/DummyClientKeyFile.jks");

AdminClient adminClient = null; 
try 
adminClient = AdminClientFactory.createAdminClient(connectProps); 
System.out.println("Connected Successfully");
catch (Exception e) 
System.out.println("Exception creating admin client: " + e); 
e.printStackTrace();
}
} catch (Exception e) {
e.printStackTrace();
}
}

No comments: