Hi Dilusha,

You can achieve your requirement with below sample API configuration.

<api xmlns="http://ws.apache.org/ns/synapse"; name="TestAPI" context="/abc">
   <resource methods="GET" uri-template="/instance/info/{id}">
      <inSequence>
         <log>
            <property name="in" value="===== IN ====="/>
         </log>
         <cache scope="per-host"
                collector="false"

hashGenerator="org.wso2.carbon.mediator.cache.digest.REQUESTHASHGenerator"
                timeout="60">
            <onCacheHit>
               <log>
                  <property name="cachehit" value="Cache is hit"/>
               </log>
            </onCacheHit>
            <implementation type="memory" maxSize="100"/>
         </cache>
         <send>
            <endpoint>
               <http uri-template="
http://www.mocky.io/v2/5a158a1f2e00005f00eab752"/>
            </endpoint>
         </send>
      </inSequence>
      <outSequence>
         <log>
            <property name="out" value="=== OUT ===="/>
         </log>
         <cache scope="per-host" collector="true"/>
         <send/>
      </outSequence>
   </resource>
</api>

Thanks,
/Susankha.


On Wed, Nov 29, 2017 at 1:34 PM, Dilusha Alphonso <[email protected]> wrote:

> Hi All,
>
> I have created an API in wso2 ESB 5.0.0  to call the SOAP back-end
> service. I have used cache mediator for a normal GET method.  What I want
> is, I have used a GET Method to get some details, I passed the id with the
> URL.
>
> Requirement- When I call the service through API for a given id in the
> first time I need a proper response for particular id, then for next call
> for the same id it should get the response from the cache itself up-to-the
> given Timeout period. if I change the id then it should hit the service.
>
> I attached my configuration.
>
> <api xmlns="http://ws.apache.org/ns/synapse"; name="Durdan"
> context="/test">
>  <resource methods="GET" uri-template="/{+patientId}">
>       <inSequence>
>          <property name="SymboValue" expression="get-property('uri.
> var.patientId)"/>
>          <cache id="someCache" scope="per-host" collector="false"
> hashGenerator="org.wso2.carbon.mediator.cache.digest.REQUESTHASHGenerator"
> timeout="60">
>         <implementation type="memory" maxSize="10"/>
>      </cache>
>                      <log>
>                   <property name="88888888888888" value="out the
> sequence"/>
>                </log>
>                <payloadFactory media-type="xml">
>                   <format>
>                      <soapenv:Envelope xmlns:soapenv="http://schemas.
> xmlsoap.org/soap/envelope/">
>                         <soapenv:Header>
>                            <some>12</some>
>                         </soapenv:Header>
>                         <soapenv:Body>
>                            <ser:readMediData xmlns:ser="http://service.
> sample.durdans.com">
>                               <ser:patientId>$1</ser:patientId>
>                            </ser:readMediData>
>                         </soapenv:Body>
>                      </soapenv:Envelope>
>                   </format>
>                   <args>
>                      <arg evaluator="xml" expression="get-property('uri.
> var.patientId')"/>
>                   </args>
>                </payloadFactory>
>          <header name="Action" value="urn:readMediDataRecords"/>
>          <property name="SOAPAction" value="urn:readMediData"
> scope="transport"/>
>          <send>
>             <endpoint>
>                <address uri="Endpoint URL" format="soap11"/>
>             </endpoint>
>          </send>
>       </inSequence>
>       <outSequence>
>         <cache id="someCache" scope="per-host" collector="true"/>
>          <send/>
>       </outSequence>
>    </resource>
> </api>
>
>
> Above configuration, I was able to get the response for proper id. but
> cache mediator is not working.
>
>
> Can anyone help me to solve this??
>
> Thanks in advance.
> --
>
>
> *Best Regards,Dilusha Alphonso*
>
> *Software Engineer - Support Team*
>
>
> *WSO2*
> *Mobile : *
>
> *+94766837098 <+94%2076%20683%207098>[image: http://wso2.com/signature]
> <http://wso2.com/signature>*
>
> _______________________________________________
> Dev mailing list
> [email protected]
> http://wso2.org/cgi-bin/mailman/listinfo/dev
>
>


-- 
Susankha Nirmala
Senior Software Engineer
WSO2, Inc.: http://wso2.com
lean.enterprise.middleware

Mobile : +94 77 593 2146
blog : https://susankhanirmala.wordpress.com/
_______________________________________________
Dev mailing list
[email protected]
http://wso2.org/cgi-bin/mailman/listinfo/dev

Reply via email to