Topic
5 replies Latest Post - ‏2014-12-16T18:56:37Z by JimRussell
samuels
samuels
63 Posts
ACCEPTED ANSWER

Pinned topic help with dp-url open

‏2013-12-23T15:35:37Z |

hello all,

here is my code

<xsl:variable name="code" select="dp:variable('var://service/error-code')"/>

<xsl:variable name="response">
                    <dp:url-open target="service1">
                                          .....request....
                    </dp:url-open>
                </xsl:variable>

<xsl:variable name="var1">      

  <xsl:choose>

<xsl:when test="$code = '0x01130006' or $code = '0x01130007'or $code = '0x00030001' or $code = '0x0113001e' or $code = '0x0313002a'">
    <xsl:value-of select="document('local://.abc.xml')/abc"/>
    </xsl:when>
    <xsl:otherwise>
                  <xsl:value-of select="$response"/>
    </xsl:otherwise>
       </xsl:choose>

here my requirement is when the Service1 is up or connection is succefull the "Response" from dp:url-open should be stored in "var1" if the "service1" is down or conenction is failed "var1" value should be "document('loacl:///abc.xml')/abc"......but the above code is not working for me. can we use the Error codes in this case?

  • Daviiid
    Daviiid
    282 Posts
    ACCEPTED ANSWER

    Re: help with dp-url open

    ‏2013-12-24T10:35:14Z  in response to samuels

    Hello Sam

    Do you apply this styleSheet in a response rule or a error rule ?

    • samuels
      samuels
      63 Posts
      ACCEPTED ANSWER

      Re: help with dp-url open

      ‏2013-12-24T18:44:22Z  in response to Daviiid

      Hello Daviid,

      The stylesheet is used in the Both Directions rule. my question is can we use the error codes when dp-url open service call fails?

      • HermannSW
        HermannSW
        4141 Posts
        ACCEPTED ANSWER

        Re: help with dp-url open

        ‏2013-12-25T00:15:35Z  in response to samuels

        Hi,

        sorry, failing <dp:url-open> does not populate error variables.

        What you can do is specify  @response  entry of <dp:url-open> as  response="responsecode".
         

        Below you can see first response for a non-existing file, and then for an existing file.
        In case "/url-.open/responsecode" is 200, you can get repsonse by "/url-open/response/*".

        $ echo "<foobar/>" | coproc2 url-open.xsl - http://dp1-l2:2223 ; echo
        <url-open><responsecode>404</responsecode><errorcode>196609</errorcode><errorstring>illegal character '>' at offset 49 of http://stamm-wilbrandt.de/ab.xml_</errorstring><content-type>text/html; charset=iso-8859-1</content-type><headers><header name="Date">Wed, 25 Dec 2013 00:12:27 GMT</header><header name="Server">Apache</header><header name="Content-Type">text/html; charset=iso-8859-1</header></headers></url-open>
        $
        $ vi url-open.xsl
        $ echo "<foobar/>" | coproc2 url-open.xsl - http://dp1-l2:2223 ; echo
        <url-open><responsecode>200</responsecode><content-type>text/xml</content-type><headers><header name="Date">Tue, 24 Dec 2013 23:48:12 GMT</header><header name="Server">Apache</header><header name="Last-Modified">Thu, 24 Oct 2013 21:31:56 GMT</header><header name="ETag">"28d534-12-4e9835cf0561c"</header><header name="X-Powered-By">PleskLin</header><header name="Content-Type">text/xml</header><header name="Age">1466</header></headers><response><a>1<b>2</b>3</a></response></url-open>
        $
        $ cat url-open.xsl
        <xsl:stylesheet version="1.0"
          xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
          xmlns:dp="http://www.datapower.com/extensions"
          extension-element-prefixes="dp"
        >
          <xsl:output omit-xml-declaration="yes" />
            
          <xsl:template match="/">
            <xsl:variable name="result">
              <dp:url-open response="responsecode" target="http://stamm-wilbrandt.de/ab.xml" />
            </xsl:variable>

            <xsl:copy-of select="$result"/>
          </xsl:template>

        </xsl:stylesheet>
        $


        Hermann<myXsltBlog/> <myXsltTweets/> <myCE/> <myFrameless/>

        Updated on 2013-12-25T00:18:17Z at 2013-12-25T00:18:17Z by HermannSW
        • dpbuddy
          dpbuddy
          32 Posts
          ACCEPTED ANSWER

          Re: help with dp-url open

          ‏2014-12-16T18:25:08Z  in response to HermannSW

          Hi All,

             I have same kind of issue in my scenario. I call my backend by using dp:url-open .

          <xsl:variable name="response">
                      <dp:url-open target="{$targetURL}" http-headers="$headers" http-method="post" data-type="xml" response="responsecode" timeout="{$timeout}">
                          <xsl:copy-of select="$request"/>
                      </dp:url-open>
                  </xsl:variable>

          and in the response I get  200 response code , errorcode and error message .There is no response from the back end (I know that the message size grater than what I have specified in my xml manager).

          <url-open xmlns:dp="http://www.datapower.com/schemas/management" xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">
          <responsecode>200</responsecode>
          <errorcode>196611</errorcode>
          <errorstring>document size limit of 51200 bytes exceeded, aborting</errorstring>
          <content-type>text/xml; charset=ISO-8859-1</content-type>
          <headers>
          <header name="Vary">Accept-Encoding</header>
          <header name="Content-Type">text/xml; charset=ISO-8859-1</header>
          <header name="Content-Language">en-US</header></headers></url-open>

           I cann't implement above solution in my xslt.

          I am wondering is there any document which can describe these dp:url-open error codes (<errorcode>196611</errorcode>) .If  I have those error code  list I can handle it properly in my error rule.Otherwise I just cann't relay on error message to handle errors.

          Thanks

          • JimRussell
            JimRussell
            37 Posts
            ACCEPTED ANSWER

            Re: help with dp-url open

            ‏2014-12-16T18:56:37Z  in response to dpbuddy

            Convert the errorcode to hex, and then look it up in "Administration / Debug / View List of Event Codes" in the WebGUI.

            hex(196611) = 0x00030003

            0x00030003 parser error

            XML parser limits exceeded