Writing a Custom Result Checker

A result checker is a custom Java class that implements error checking for mobile business objects (MBOs).

Not all MBO operations use a "standard" error reporting technique; you may want to implement your own custom result checker. Doing so allows you to check any field for errors, or implement logic that determines what constitutes an error, and the severity of the error. The error code and message can be influenced in the result checker by throwing a DSException

  1. Provide a Java class that implements the appropriate interface.
    Data source Interface
    SAP
    package com.sybase.sup.sap;
    public interface SAPResultChecker
    {
        /**
         * 
         * @param f - JCO function that has already been executed. 
         * Use the JCO API to retrieve returned values and determine if the RFC has executed
         * successfully.
         * @return a single Map.Entry. The boolean "key" value should be set to true if the
         * RFC is deemed to have succeeded. Normal result processing will ensue.<P>
         * If the String value is not empty/null, that value will be treated as a warning message, 
         * which will be logged on the server, 
         * and returned as a warning in transaction logs to the client.<P>
         * Set the key value to false if it is deemed the RFC has failed. The String value will
         * be thrown in the body of an exception. The error will be logged on the server, and the
         * client will receive a transaction log indicating failure, including the string value.
         */
        Map.Entry<Boolean, String> checkReturn(JCO.Function f);
    }
    
    Web service (SOAP)
    package com.sybase.sup.ws.soap;
    public interface WSResultChecker
    {
        /**
         * @param is the method for passing a parameter, and does not support setting a 
           default value.
         * @param response – the SOAP Envelope response from a Web service execute.
         * Use the SOAP API to retrieve values and determine if the SOAP request
         * has executed successfully.
         * @return a single Map.Entry. The boolean "key" value should be set to true if the
         * SOAP request is deemed to have succeeded. Normal result processing will ensue.<P>
         * If the String value is not empty/null, that value will be treated as a warning message, 
         * which will be logged on the server, 
         * and returned as a warning in transaction logs to the client.<P>
         * Set the key value to false if it is deemed that SOAP has failed. The String value will
         * be thrown in the body of an exception. The error will be logged on the server, and the
         * client will receive a transaction log indicating failure, including the string value.
         */
        Map.Entry<Boolean, String> checkReturn(javax.xml.soap.SOAPEnvelope response);
    }
    
    RESTful Web service
    package com.sybase.sup.ws.rest;
    
    import java.util.List;
    import java.util.Map;
    
    public interface RestResultChecker 
    {
    	/** 
    	 * REST Result Checker.
    	 *
    	 * @param responseBody HTTP response body.
    	 *
    	 * @param responseHeaders HTTP response headers in the form
    	 * {{header1,value1}, {header2,value2}, ...}.
    	 *
    	 * @param httpStatusCode HTTP status code.
    	 *
    	 * @return Single Map.Entry whose boolean "key" value is true if the 
    	 * HTTP request succeeded, after which normal result processing will
    	 * ensue.<P> 
    	 *
    	 * If the String value is not empty/null, that value will be treated
    	 * as a warning message which will be logged on the server and returned
    	 * as a warning in the transaction log sent to the client.<P> 
    	 *
    	 * Set the key value to false if it is deemed that the service has failed.
    	 * The String value will be thrown in the body of an exception. The error
    	 * will be logged on the server, and the client will receive a transaction
    	 * log indicating failure, including the string value. 
    	 **/ 
    	Map.Entry<Boolean, String> checkReturn( String responseBody,
    			List<List<String>> responseHeaders, int httpStatusCode );
    } 

    Result checkers depend on the sup-ds.jar file, in com.sybase.uep.tooling.api/lib subdirectory. For example, C:\Sybase\UnwiredPlatform-1_5\Unwired_WorkSpace\Eclipse\sybase_workspace\mobile\eclipse\plugins\com.sybase.uep.tooling.api_1.5.0.200909281740\lib

  2. Save any classes you create to an accessible Unwired WorkSpace location. This allows you to select the class when you configure the result checker for your mobile business object.