Writing a Custom Result Checker

Use a custom Java class to implement custom error checking.

Provide a Java class that extends the appropriate class for the enterprise information system (EIS).
  • SAP
    package com.sybase.sup.sap3;
    
    import com.sap.conn.jco.JCoFunction;
    import com.sybase.vader.core.OperationHandlerBase;
    
    public abstract class SAPOperationHandler extends OperationHandlerBase {
     
     /**
      * 
      * @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.
      * 
      * Throw OHException to return an error.
      * Call OHLog.log() as often as needed to return 
      * warnings and other informational messages.
      */
     public void resultCheck(JCoFunction f) {
     }
     
     /** 
      * @param cause Exception thrown by the call to the EIS
      * 
      * @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.
      * 
      * Throw OHException to return an error.
      * Call OHLog.log() as often as needed to return warnings 
      * and other informational messages.
      */ 
     public void onError(Throwable cause, JCoFunction f) {
     }
    }
    
  • Web service (SOAP)
    package com.sybase.sup.ws.soap;
    
    import com.sybase.vader.core.OperationHandlerBase;
    
    public abstract class SoapOperationHandler extends OperationHandlerBase {
    
        /** 
         * 
         * @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. 
         * 
         * @param request the SOAP Envelope request sent to 
         * the web service. 
         * Use the SOAP API to retrieve values. 
         * 
      * Throw OHException to return an error.
      * Call OHLog.log() as often as needed to return warnings 
      * and other informational messages.
         * 
         */ 
     public void resultCheck(
          javax.xml.soap.SOAPEnvelope response, 
          javax.xml.soap.SOAPEnvelope request) {
     } 
     
        /** 
         * @param cause Exception thrown by the call to the EIS
         * 
         * @param request the SOAP Envelope request sent to the 
         * web service. 
         * Use the SOAP API to retrieve values. 
         * 
      * Throw OHException to return an error.
      * Call OHLog.log() as often as needed to return warnings 
      * and other informational messages.
      * 
         */ 
     public void onError(Throwable cause, 
       javax.xml.soap.SOAPEnvelope request) {
     }
    }
    
  • RESTful Web service
    package com.sybase.sup.ws.rest;
    
    import java.util.List;
    import com.sybase.vader.core.OperationHandlerBase;
    
    import java.net.URL;
    
    
    public abstract class RestOperationHandler extends OperationHandlerBase{
     
     
     public RestOperationHandler () {
      super();
     }
     
     /** 
      * REST Result Check.
      *
      * @param responseBody HTTP response body.
      *
      * @param responseHeaders HTTP response headers in the form
      * {{header1,value1}, {header2,value2}, ...}.
      *
      * @param httpStatusCode HTTP status code.
      *
      * @param url HTTP URL.
      *
      * @param requestBody HTTP request body.
      *
      * @param requestHeaders HTTP request headers in the form
      * {{header1,value1}, {header2,value2}, ...}.
      *
      * Throw OHException to return an error.
      * Call OHLog.log() as often as needed to return warnings 
      * and other informational messages.
      * 
      **/ 
     public void resultCheck( String responseBody,
        List<List<String>> responseHeaders, int httpStatusCode, URL url,
             String requestBody, List<List<String>> requestHeaders) {
     }
     
        /** 
         * REST On Error
         * Note that errors are virtually never thrown by REST.  
         * Instead, HTTP Error codes are returned.  
         * The Result Check method can handle these codes 
         * before any exception is thrown by Data Services.
         * 
         * @param cause Exception thrown by the call to the EIS
      *
      * @param url HTTP URL.
      *
      * @param requestBody HTTP request body.
      *
      * @param requestHeaders HTTP request headers in the form
      * {{header1,value1}, {header2,value2}, ...}.
         * 
      * @return Result Checker Return
      *
      * Throw OHException to return an error.
      * Call OHLog.log() as often as needed to return warnings 
      * and other informational messages.
      * 
         */ 
     public void onError(Throwable cause, URL url,
             String requestBody, List<List<String>> requestHeaders) {
     }
    }

Result checkers depend on the SAP Mobile Server sup-ds.jar file. For example, SMP_HOME\Servers\UnwiredServer\lib\ext\sup-ds.jar.