RaiseFault with condition

`<RaiseFault name="noname-prevention">
<FaultResponse>
<Set>
<StatusCode>{private.message.noname.code}</StatusCode>
<Payload/>
<Headers>
<Header name="x-blocked-by-noname">{private.message.noname.header.value}</Header>
</Headers>
</Set>
</FaultResponse>
</RaiseFault>
`
Can I add a condition before `set` to verify `{private.message.noname.header.value}` is not null?

Solved Solved
2 1 74
1 ACCEPTED SOLUTION

You can do this in the flow: 

  <Step>
    <Name>RF-Noname-Prevention-With-Message</Name>
    <Condition>private.message.noname.blocked != null</Condition>
  </Step>
  <Step>
    <Name>RF-Noname-Prevention-Without-Message</Name>
    <Condition>private.message.noname.blocked = null</Condition>
  </Step>
   ...

Or you can use an AssignVariable with a template in the policy like this: 

<RaiseFault name='RF-Blocked'>
 <FaultResponse>
  <AssignVariable>
    <Name>my-variable</Name>
    <Ref>private.message.noname.header.value</Ref>
    <Value>-not-set-</Value>
  </AssignVariable>
  <Set>
   <StatusCode>{private.message.noname.code}</StatusCode>
   <Headers>
    <Header name="x-blocked-by-noname">{my-variable}</Header>
   </Headers>
  </Set>
 </FaultResponse>
</RaiseFault>

...which will set my-variable to -not-set- if the private.message.noname.header is null. 

View solution in original post

1 REPLY 1

You can do this in the flow: 

  <Step>
    <Name>RF-Noname-Prevention-With-Message</Name>
    <Condition>private.message.noname.blocked != null</Condition>
  </Step>
  <Step>
    <Name>RF-Noname-Prevention-Without-Message</Name>
    <Condition>private.message.noname.blocked = null</Condition>
  </Step>
   ...

Or you can use an AssignVariable with a template in the policy like this: 

<RaiseFault name='RF-Blocked'>
 <FaultResponse>
  <AssignVariable>
    <Name>my-variable</Name>
    <Ref>private.message.noname.header.value</Ref>
    <Value>-not-set-</Value>
  </AssignVariable>
  <Set>
   <StatusCode>{private.message.noname.code}</StatusCode>
   <Headers>
    <Header name="x-blocked-by-noname">{my-variable}</Header>
   </Headers>
  </Set>
 </FaultResponse>
</RaiseFault>

...which will set my-variable to -not-set- if the private.message.noname.header is null.