Knowledge Base > Automation Engine and Target Systems > Java EE/JMX > Generating MBeans from Webservices

Generating MBeans from Web Services

Guideline for the creation of MBeans based on Web services.

Knowledge of Java and Web services is required in order to be able to fully understand this guideline.

AE provides support neither for Web services nor for MBeans.

General

The Automation EngineThis component drives an Automation Engine system and consists of different types of server processes. supports Web services through the usage of MBeans in combination with the JMX agentA program that enables the de-centralized execution of processes (such as deployments) on target systems (computers or business solutions) or a service that provides connectivity to a target system (such as for databases or middleware). An agent is also an object type in the Automation Engine. [Formerly called "Executor."] See also: host. Many vendors offer Web services rather than MBeans as interfaces that provide access to their applications. This guideline describes step by step how an MBean is generated from an existing Web service. The Web service "CurrencyConvertor" which is provided by Generic Objects Technologies Ltd serves as an example. It supplies currency exchange rates.

Requirements:

MBeans can only be created for synchronous Web services. Using asynchronous  Web services is much more difficult and must be handled individually.

Thoroughly test the generated MBean.

Installation

1.

Setting up Apache Axis

2.

Generating Java classes for calling the Web service

3.

Creating an MBean for using the Java classes

ConverterMBean.java:

package com.uc4.ws;

import java.rmi.RemoteException;
import javax.xml.rpc.ServiceException;

public interface ConverterMBean {
double convertCurrency(String fromCurrency, String toCurrency)
throws ServiceException, RemoteException, IllegalArgumentException;
}

Converter.java:

package com.uc4.ws;

import java.rmi.RemoteException;
import javax.xml.rpc.ServiceException;
import NET.webserviceX.www.Currency;
import NET.webserviceX.www.CurrencyConvertorLocator;
import NET.webserviceX.www.CurrencyConvertorSoap;

public class Converter implements ConverterMBean {
public double convertCurrency(String fromCurrency, String toCurrency)
throws ServiceException, RemoteException, IllegalArgumentException {
CurrencyConvertorLocator locator = new CurrencyConvertorLocator();
CurrencyConvertorSoap soap = locator.getCurrencyConvertorSoap();
return soap.conversionRate(
Currency.fromString(fromCurrency),
Currency.fromString(toCurrency));
}
}

The method "convertCurrency" contains the Web service call. Therefore, it uses the generated Java classes. It creates a service-locator instance and calls the method  "getCurrencyConvertorSoap" in order to obtain a SOAP stub. This pattern (locator-stub) is described in the Apache Axis documentation.

The stub calls the Web service. The parameters are converted from "java.lang.String" to "NET.webserviceX.www.Currency" objects because only simple data types can be used in MBeans. The supplied result is the current currency conversion rate.

4.

Creating the MBean's JAR file and the Java classes

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<project name="uc4" default="exampleMBean.jar">
<property name="classes_dir" value="bin" />
<target name="exampleMBean.jar" description="Web Service MBean">
<jar jarfile="exampleMBean.jar" basedir="${classes_dir}"/>
</target>
</project>

No ant script is required in development environments such as Eclipse. Here you can generate the JAR file via menu command.

5.

Starting the JMX Agent using an MBean

Java -cp axis.jar;commons-discovery-0.2.jar;commons-logging-1.0.4.jar;
wsdl4j-1.5.1.jar;saaj.jar;exampleMBean.jar;ucxjjmx.jar;jaxrpc.jar com/uc4/ex/jmx/UCXJMX

UNIX: use a colon (":") instead of a semicolon (";").

The JMX agent does not require an applicationAn application is a software which helps a user to fulfill specific tasks. In the context of ARA see also: Application entity. server but can run independently. It is sufficient to install the Java version 5 as it contains the required JMX packagesDelivery package, a bundle of functionality. of version 1.2.

Usage

1.

Creating a JMX jobAn Automation Engine object type for a process that runs on a target system.

2.

Using the MBean

 

 


Automic Documentation - Tutorials - Automic Blog - Resources - Training & Services - Automic YouTube Channel - Download Center - Support

Copyright © 2016 Automic Software GmbH