IBM webMethods Hybrid Integration

IBM webMethods Hybrid Integration

Join this online group to communicate across IBM product users and experts by sharing advice and best practices with peers and staying up to date regarding product enhancements.



#Automation


#Applicationintegration
#webMethods
#Integration
 View Only
  • 1.  REST request processing to set http status code and message

    Posted 06/11/19 06:42 AM

    Dears,

    On API Gateway 10.3, I am using a request processing, over REST Virtual Service, that invokes a java service, in order to apply some validations. Whenever the validations are not succeeded one exception is raised (to stop the execution) and the http status code and messages are adapted.

    To execute a manipulation of the http status code and message I am applying:

    [size=9]private static void setStatusCode(int statusCode, String statusMessage, RestMessageContext msgCtx) throws ServiceException{

    	HTTPResponse response = (HTTPResponse) msgCtx.getHttpResponse();
    response.getHeader().setResponse(statusCode, statusMessage);
    msgCtx.setProperty(HTTPConstants.MC_HTTP_STATUS_CODE, statusCode);
    
    throw new ServiceException(statusMessage);
    

    }[/size]

    However, it seems the values set on “setResponse” and “setProperty” are totally ignored, since it always returns HTTP Status Code “500” and Message “Internal Server Error”.

    Any idea what is missing here?

    Thanks and regards.


    #API-Gateway
    #API-Management
    #webMethods


  • 2.  RE: REST request processing to set http status code and message

    Posted 06/11/19 07:12 AM

    Hi,

    The request/response transformation is a lot simpler in 10.2+ releases. Can you check http://techcommunity.softwareag.com/pwiki/-/wiki/Main/Invoke+webMethods+IS+policy+in+API+Gateway+10.2?

    This also provides information on how to transform the status code.

    Regards,
    Praveen


    #API-Gateway
    #webMethods
    #API-Management


  • 3.  RE: REST request processing to set http status code and message

    Posted 06/11/19 09:05 AM

    Praveen, thanks for your reply.

    I had already read the tutorial and only indicates how to transform the status code on Response Processing and Error Handling phases.

    I think, to apply the transformation on Request Processing it must be programmatically, but could not find a way.

    Regards.


    #API-Gateway
    #API-Management
    #webMethods


  • 4.  RE: REST request processing to set http status code and message

    Posted 06/13/19 05:34 AM

    Hi João Felisberto,

    If you want to transform anything in response, you should only do them in response stage (hence, Response processing and Error handling policies).

    As a workaround to your use case, can you try throwing an exception from your IS service in request processing stage, and transform the resulting 500 status code to your own status code, by configuring another IS service in error handling policy.

    Regards,
    Vallab.


    #API-Gateway
    #API-Management
    #webMethods