IBM WebSphere DataPower Community Forum IBM Webspere DataPower XI50
October 12, 2008, 03:18:08 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News: IBM WebSphere DataPower SOA Appliance Forum - Just Launched come share your knowledge!!! These forums will be a great place to build a community. This site is not associated with IBM.
 
   Home   Help Search Login Register  
Pages: [1]   Go Down
  Print  
Author Topic: Branching based on value of a Soap field... to call a rule  (Read 396 times)
anboss
Newbie
*
Offline Offline

Posts: 24

an_boss
View Profile WWW Email
« on: December 11, 2007, 07:31:53 AM »

can somebody help me with achieving the following functionality:

Based on the value of a field that i get in the xml or soap input, within a policy, i need to select a processing rule. How is this possible.

For instance:

<inputOperation soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xsi:type="xsd:string">Retrieve</inputOperation>

is the field.. and "Retrieve" is the value then Retrieve_Rule should be called. If the value is "Add" then Add_Rule should be called and so on. In the Add_Rule, Retrieve_Rule i am transforming the soap input to some other formats respectively.

Can this be acieved.

Please help.
Thanks in advance.
Logged
vickarth
Newbie
*
Offline Offline

Posts: 4


View Profile Email
« Reply #1 on: December 11, 2007, 08:37:18 AM »

Hi anboss,

You can achieve this by using the Call Processing Rule Action (Advance actions)

The full details are as follows:

Step 1:After Match Action you have to add a Transform action with a XSL stylesheet doing the following:
Find out whats the value in the input XML (Retrieve/Add) via XPATH
Based on the extracted value set a DP context variable to the other rule name(Retrieve_Rule/Add_Rule)

Step 2:Insert a Call Processing Rule Action and set the Processing Rule field here to the DP context variable set earlier in the XSL(Use Variable Builder).

Step 3:Create Retrieve_Rule and Add_Rule as required (Rule Names should match to ones in XSL)

The XSL code snippet is given below

 <xsl:template match="/">
     <xsl:variable name="callname" select="/inputOperation" />
   <xsl:choose>
      <xsl:when test="$callname = 'Retrieve'">
         <dp:set-variable name="'var://context/test/nextrule'" value="'Retrieve_Rule'" />
       </xsl:when>
       <xsl:otherwise>
         <dp:set-variable name="'var://context/test/nextrule'" value="'Add_Rule'" />
       </xsl:otherwise>
    </xsl:choose>
   </xsl:template>

Attached is a screen shot of the policy.

Hope this helps....try out and let me know

Chees!!
vickarth
Logged
LordB
Administrator
Newbie
*****
Offline Offline

Posts: 45


View Profile
« Reply #2 on: December 11, 2007, 10:11:35 AM »

You could also just do a match rule that uses an xpath expression.


Byron
Logged
anboss
Newbie
*
Offline Offline

Posts: 24

an_boss
View Profile WWW Email
« Reply #3 on: December 12, 2007, 12:35:00 AM »

In the call step i get the following error

xmlfirewall (nbktz9z_Operations_StringOperationsService): request nbktz9z_Operations_StringOperationsService_Rule_0 #2 CALL rule var://context/test/nextrule with input tempvar1 and output tempvar2 failed: Bad rule in CALL

i am attaching the xsl i used. In the transformation step i have just mentioned the xsl file name. the output of this step is tempvar1. which goes as input to call. in the call step i am using a context variable for selecting 'next' rules. when i send request.. i get this error. why is this so?
« Last Edit: December 12, 2007, 12:58:16 AM by anboss » Logged
vickarth
Newbie
*
Offline Offline

Posts: 4


View Profile Email
« Reply #4 on: December 13, 2007, 06:30:47 AM »

Hi Anboss,

You get a "Bad rule in CALL" error when the Rule Name is not set properly in the variable.

Also I am not sure why you are using dpedu="http://dpedu.ibm.com" namespace for dp extention elements.

I guess you getting the error because you are not including the extension-element-prefixes and exclude-result-prefixes attributes in the stylesheet elements.

Try the following stylesheet declaration :
Code:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:dpedu="http://www.datapower.com/extensions"
xmlns:dpconfig="http://www.datapower.com/param/config" extension-element-prefixes="dpedu"
exclude-result-prefixes="dpedu dpconfig">

Try and let me know

Cheers!!
vickarth
Logged
anboss
Newbie
*
Offline Offline

Posts: 24

an_boss
View Profile WWW Email
« Reply #5 on: December 13, 2007, 06:37:47 AM »

yeah i noticed that... even the validation of the xsl failed in that case. and i have added the namespace...

the problem seems to be something else

in the assignment step you have given the value of Rule_name in single quotes like "'Add_Rule'". i removed the single quote and just with "Add_Rule" alone i tried. it is working fine.

Thanks for the reply. Vic.
Logged
Pages: [1]   Go Up
  Print  
 
Jump to:  



Powered by SMF | SMF © 2006-2007, Simple Machines LLC
Seo4Smf © Webmaster's Talks
This Site is not associated with IBM