Topic
  • 3 replies
  • Latest Post - ‏2014-01-03T15:54:53Z by jinglerobs
RiyazShah
RiyazShah
58 Posts

Pinned topic How to set a threshold to call one service using url-open

‏2013-12-31T20:43:35Z |

Hi Everybody,

I am trying to call one service by using dp:url-open like given below,

<?xml version="1.0" encoding="UTF-8"?>

<xsl:stylesheetversion="1.0"xmlns:xsl="http://www.w3.org/1999/XSL/Transform"xmlns:fo="http://www.w3.org/1999/XSL/Format"xmlns:dp="http://www.datapower.com/extensions"exclude-result-prefixes="fo dp"extension-element-prefixes="fo dp">

<xsl:outputmethod="xml"/>

<xsl:templatematch="/">

<xsl:variablename="response">

<dp:url-opentarget="{xxxx}"response="response-code">

<xsl:text>12345</xsl:text>

</dp:url-open>

</xsl:variable>

</xsl:template>

</xsl:stylesheet>

My question is if the url-open is failed or down first time. Can i retry  to do again url-open for like maximium 3 times and then if we get the same error response in three times then, i have to send a Email notification to somebody saying that the service is down.

2.when do we have to use { } for the target url.

 

can anybody help me to do this in an easiest approach.

Thanks!

R@j

 

Updated on 2014-01-03T15:29:11Z at 2014-01-03T15:29:11Z by RiyazShah
  • jinglerobs
    jinglerobs
    35 Posts

    Re: How to set a threshold to call one service using url-open

    ‏2014-01-02T08:51:14Z  

    From dp-url open documentation there is no option to specify retries. What you can do is put try catch and implement 3 times check whether dp-url open call failed or not . Use {} in target url when using variables.

    ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

    <xsl:variable name="url" value="http://abc.com/uri"/>

    <!-- Try mechanism 1 -->
    <xsl:variable name="response1">
    <dp:url-open target="{$url}"response="responsecode">
    <xsl:text>12345</xsl:text>
    </dp:url-open>
    </xsl:variable>


     <xsl:choose>

     <!-- Check if first try failed -->
     <xsl:when test="$response1/url-open/responsecode != '200' or $response1/url-open/statuscode != '0'">

      <!-- Capture error string -->
      <dp-set-variable name="var://context/myerrorcontext/err1" value="$response1/url-open/errorstring"/>

      <!-- Try mechanism 2 -->
      <xsl:variablename="response2">
      <dp:url-open target="{$url}"response="responsecode">
      <xsl:text>12345</xsl:text>
      </dp:url-open>
      </xsl:variable>


      <!-- Check if second try failed -->
      <xsl:if test="$response2/url-open/responsecode != '200' or $response2/url-open/statuscode != '0'">

       <!-- Capture error string -->
       <dp-set-variable name="var://context/myerrorcontext/err2" value="$response2/url-open/errorstring"/>

       <!-- Try mechanism 3 -->
       <xsl:variablename="response3">
       <dp:url-open target="{$url}"response="responsecode">
       <xsl:text>12345</xsl:text>
       </dp:url-open>
       </xsl:variable>

       <!-- Check if third try failed -->
       <xsl:if test="$response3/url-open/responsecode != '200' or $response3/url-open/statuscode != '0'">

        <!-- Capture error string -->
        <dp-set-variable name="var://context/myerrorcontext/err3" value="$response3/url-open/errorstring"/>

        <!-- Check if all 3 context variables contain same error string -->

        <!-- Send email code here-->

       </xsl:if>
      </xsl:if>
     </xsl:when>

    <xsl:otherwise>

    <!-- Do success code -->

    </xsl:otherwise>

    </xsl:choose>

    ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

  • RiyazShah
    RiyazShah
    58 Posts

    Re: How to set a threshold to call one service using url-open

    ‏2014-01-03T15:32:06Z  

    From dp-url open documentation there is no option to specify retries. What you can do is put try catch and implement 3 times check whether dp-url open call failed or not . Use {} in target url when using variables.

    ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

    <xsl:variable name="url" value="http://abc.com/uri"/>

    <!-- Try mechanism 1 -->
    <xsl:variable name="response1">
    <dp:url-open target="{$url}"response="responsecode">
    <xsl:text>12345</xsl:text>
    </dp:url-open>
    </xsl:variable>


     <xsl:choose>

     <!-- Check if first try failed -->
     <xsl:when test="$response1/url-open/responsecode != '200' or $response1/url-open/statuscode != '0'">

      <!-- Capture error string -->
      <dp-set-variable name="var://context/myerrorcontext/err1" value="$response1/url-open/errorstring"/>

      <!-- Try mechanism 2 -->
      <xsl:variablename="response2">
      <dp:url-open target="{$url}"response="responsecode">
      <xsl:text>12345</xsl:text>
      </dp:url-open>
      </xsl:variable>


      <!-- Check if second try failed -->
      <xsl:if test="$response2/url-open/responsecode != '200' or $response2/url-open/statuscode != '0'">

       <!-- Capture error string -->
       <dp-set-variable name="var://context/myerrorcontext/err2" value="$response2/url-open/errorstring"/>

       <!-- Try mechanism 3 -->
       <xsl:variablename="response3">
       <dp:url-open target="{$url}"response="responsecode">
       <xsl:text>12345</xsl:text>
       </dp:url-open>
       </xsl:variable>

       <!-- Check if third try failed -->
       <xsl:if test="$response3/url-open/responsecode != '200' or $response3/url-open/statuscode != '0'">

        <!-- Capture error string -->
        <dp-set-variable name="var://context/myerrorcontext/err3" value="$response3/url-open/errorstring"/>

        <!-- Check if all 3 context variables contain same error string -->

        <!-- Send email code here-->

       </xsl:if>
      </xsl:if>
     </xsl:when>

    <xsl:otherwise>

    <!-- Do success code -->

    </xsl:otherwise>

    </xsl:choose>

    ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

    Hi,

    thanks for your reply, I tried like this too but it didn't work. Does anybody have alternative ideas.

     

    Thanks!

    R@j

     

     

     

  • jinglerobs
    jinglerobs
    35 Posts

    Re: How to set a threshold to call one service using url-open

    ‏2014-01-03T15:54:53Z  
    • RiyazShah
    • ‏2014-01-03T15:32:06Z

    Hi,

    thanks for your reply, I tried like this too but it didn't work. Does anybody have alternative ideas.

     

    Thanks!

    R@j

     

     

     

    What is the exact issue that you are facing in code ?