Error message

The following error message is reported when a High-speed Service Framework (HSF) service is called:
There is no TOP transformer for Service:[${serviceUniqueName}].

Solution

The Taobao Open Platform (TOP) call method prevents the gateway application from depending on the API package of the backend service. When the TOP call is transformed on the server, the corresponding transformer is not found.

Configure the client

The client uses com.taobao.hsf.app.spring.util.SuperHSFSpringConsumerBeanTop. This class does not need the API package of the server. It calls the API by using com.taobao.hsf.app.spring.util.SuperHSFSpringConsumerBeanTop#invoke.

The following sample code provides an example on how to configure the client:

/**
 * TOP calls this method to remotely access the HSF service. 
 * <p>
 * The parameterTypes parameter indicates the type of the parameter of the method to be called.  It must be a complete Java class name. If the parameter is an atomic type, the type is the name of the atomic type. 
 * </p>
 * 
 * @return Returns the peer service response or service error.
 * 
 * @throws HSFException
 *             If an error occurs at the local or peer HSF layer, HSFException is thrown.
 * @throws Throwable
 *              If an error occurs on the server, Exception is thrown.
 */
public Object invoke(String methodName, String[] parameterTypes, Object[] args) throws HSFException, Throwable {
    return consumerBeanTop.invoke(methodName, parameterTypes, args);
}
            

Here args is not the actual service type of the server.

Configure the server

When the server is initialized, com.taobao.hsf.ServiceInvokeTransform.Helper#register is called to register a transformer.

The following sample code provides an example on how to configure the server:
/**
 * It is used to convert the service call parameters into a format that is acceptable to the service. 
 * 
 * @param methodName
 *            The name of the service method to be called.
 * @param args
 *            The call parameter before conversion.
 * @param parameterTypes
 *            The real parameter type of the service method to be called.
 */
abstract public Object[] transformRequest(String methodName, Object[] args, String[] parameterTypes)
        throws Exception;

/**
 * The type of the request parameter to be converted.
 * 
 * @param methodName
 * @param args
 * @param parameterTypes
 * @return
 * @throws Exception
 */
abstract public String[] transformRequestTypes(String methodName, Object[] args, String[] parameterTypes)
        throws Exception;
            

The transformer converts parameters transmitted by the client into real service types on the server. HSF calls the service based on converted parameters and then uses the transformer to convert the service result and then return the result to the TOP client.