Search code examples
reverse-proxyadc

OPLON LBL ADC rewrite an http body to clean a value before xml content


In the HTTP body, requests and responses, I need to clean a non xml part at the start of body when passing through LBL ADC Reverse Proxy.

The value to clean is XMLDATA= eg.:

Values in the HTTP body before rewriting:

XMLDATA=<myXmlData> ....
...
...
</myXmlData>

Expected values after body rewriting in the HTTP body:

<myXmlData> ....
...
...
</myXmlData>

thanks in advance.


Solution

  • You can use an OPLON LBL ADC body rewrite rule that uses a regular expression to clean a firs part of body response. OPLON LBL ADC is a full reverse proxy and you can inspect or modify REQUEST and RESPONSE, HEADER and BODY.

    In this case when the regex rule matches with a start string XMLDATA= the rule replace the content in the all other body data exept the start match frase.

    <rewriteBodyRule name="cleanXmlContents" flow="BOTH">
        <mimeType value="application/xml" fragmentClose="&gt;" fragmentOpen="&lt;"/>
        <regexTag>^XMLDATA\=(.*)</regexTag>
        <replaceTo>$1</replaceTo>
    </rewriteBodyRule>
    

    Keep in mind! If the HTTP body has compressed by endpoint (app/web server), you need disable the compression for that request to rewrite a body. OPLON LBL ADC compress a data body for you after rewriting...

    You have 2 way to disable compression:
    1) disable compression in the app/web server
    2) disable compression with a rewrite HEADER rule in the REQUEST HTTP header by OPLON LBL ADC.

    For case (2) you can use a Template rule in the OPLON LBL ADC.