Open topic with navigation

TIBCO BusinessEvents® Enterprise Edition 6.3.1

# Sample Code for Action Rule Function

Action rule function defined in the destination uses catalog functions to get required data and parameters from the HTTP request. The rule function processes these parameters and creates a response, similar to a preprocessor. TIBCO BusinessEvents supports all HTTP methods stated in the HTTP 1.1 specification for Action Rule Function based approach.

    void rulefunction RuleFunctions.Callback {
       attribute {
          validity = ACTION;
       }
       scope {
          Object asyncContextObject;
       }
       body {
          //getting servlet request and response objects
          Object servletRequest = HTTP.Servlet.getServletRequest(asyncContextObject);
          Object servletResponse = HTTP.Servlet.getServletResponse(asyncContextObject);
          System.debugOut("##Servlet request method : " + HTTP.Servlet.Request.getMethod(servletRequest));
          System.debugOut("##Servlet request content : " + HTTP.Servlet.Request.getRequestContent(servletRequest));
          System.debugOut("##Servlet request Requester Address : " + HTTP.Servlet.Request.getRequestorAddress(servletRequest));
          System.debugOut("##Servlet request Request URI : " + HTTP.Servlet.Request.getRequestURI(servletRequest));
          //getting parameters
          String[] params = HTTP.Servlet.Request.getRequestParameters(servletRequest);
          for(int i=0;i<params@length;i++)
          {
             System.debugOut("## Servlet request Parameters  :" + HTTP.Servlet.Request.getRequestParameter(servletRequest,params[i]));
          }
          //getting headers
          System.debugOut("## Servlet request Header Accept  : " + HTTP.Servlet.Request.getRequestHeader(servletRequest,"Accept"));
          System.debugOut("## Servlet request Header Accept-Encoding  : " + HTTP.Servlet.Request.getRequestHeader(servletRequest,"Accept-Encoding"));
          System.debugOut("## Servlet request Header Accept-Language  : " + HTTP.Servlet.Request.getRequestHeader(servletRequest,"Accept-Language"));
          System.debugOut("## Servlet request Header Accept-Charset  : " + HTTP.Servlet.Request.getRequestHeader(servletRequest,"Accept-Charset"));
          System.debugOut("## Servlet request Header Connection  : " + HTTP.Servlet.Request.getRequestHeader(servletRequest,"Connection"));
          System.debugOut("## Servlet request Header User-Agent: " + HTTP.Servlet.Request.getRequestHeader(servletRequest,"User-Agent"));
          System.debugOut("## Servlet request Header Content-Length  : " + HTTP.Servlet.Request.getRequestHeader(servletRequest,"Content-Length"));
          System.debugOut("## Servlet request Header Content-Type  : " + HTTP.Servlet.Request.getRequestHeader(servletRequest,"Content-Type"));
          System.debugOut("## Servlet request Header Host  : " + HTTP.Servlet.Request.getRequestHeader(servletRequest,"Host"));
          HTTP.Servlet.Response.setResponseHeader(servletResponse, "Content-type", "text/plain");
          HTTP.Servlet.Response.setResponseContent(asyncContextObject, "response", true);
       }
    }

Did you find this helpful?

YesNo
Great!
Thanks for taking the time to give us some feedback.
Sorry about that

Why wasn't this helpful? (check all that apply)

Could not find what I was looking for
Instructions confusing or unclear
Instructions did not work

Want to tell us more?

Please select at least one option or provide details about the issue!!

Error occurred while submitting feedback.

Error2 occurred while submitting feedback.

TIBCO BusinessEvents® Enterprise Edition

Copyright © 2004-2024. Cloud Software Group, Inc. All Rights Reserved.