Raise Fault copy function does not work anymore

Hi, can anyone help me why my Raise Fault does not work anymore during last few days. Before I deployed in APIGEE Edge UI successfully but now it shows the below message. It seems that APIGEE update XML Schema validation without notice. Thank you.

Error Saving Revision 10
Error occurred while validation of bean xxx.xml. Reason: - Schema validation failed. Cause : unexpected element (uri:"", local:"Header"). Expected elements are <{}Path>,<{}FormParams>,<{}Version>,<{}Headers>,<{}Verb>,<{}ReasonPhrase>,<{}Payload>,<{}QueryParams>,<{}StatusCode>. Line number : 7. Column number : 22. File name : xxx.xml.

My code:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<RaiseFault async="false" continueOnError="false" enabled="true" name="xxx">
    <DisplayName>xxx</DisplayName>
    <Properties/>
    <FaultResponse>
        <Copy source="response">
            <Header/>
            <Body/>
        </Copy>
    </FaultResponse>
    <IgnoreUnresolvedVariables>true</IgnoreUnresolvedVariables>
</RaiseFault>
Solved Solved
0 6 441
1 ACCEPTED SOLUTION

Hi - that's not a valid use of the policy.

From the documentation, It looks to me that the Copy element supports three child elements:

  • Headers
  • StatusCode
  • ReasonPhrase

your use of Header and Body are not supported; as far as I am aware, they have never been supported as child elements under Copy.

The actual validation message conflicts with the documentation. That message indicates that there are other elements that could be used there. But the doc doesn't say what those things do, so we should assume that they do nothing.

I suggest you correct your policy to something like this:

<RaiseFault async="false" continueOnError="false" enabled="true" name="xxx">
    <DisplayName>xxx</DisplayName>
    <Properties/>
    <FaultResponse>
        <Copy source="response">
            <Headers/>
            <StatusCode/>
            <ReasonPhrase/>
        </Copy>
    </FaultResponse>
    <IgnoreUnresolvedVariables>true</IgnoreUnresolvedVariables>
</RaiseFault>

View solution in original post

6 REPLIES 6

Hi - that's not a valid use of the policy.

From the documentation, It looks to me that the Copy element supports three child elements:

  • Headers
  • StatusCode
  • ReasonPhrase

your use of Header and Body are not supported; as far as I am aware, they have never been supported as child elements under Copy.

The actual validation message conflicts with the documentation. That message indicates that there are other elements that could be used there. But the doc doesn't say what those things do, so we should assume that they do nothing.

I suggest you correct your policy to something like this:

<RaiseFault async="false" continueOnError="false" enabled="true" name="xxx">
    <DisplayName>xxx</DisplayName>
    <Properties/>
    <FaultResponse>
        <Copy source="response">
            <Headers/>
            <StatusCode/>
            <ReasonPhrase/>
        </Copy>
    </FaultResponse>
    <IgnoreUnresolvedVariables>true</IgnoreUnresolvedVariables>
</RaiseFault>

Thanks @Dino-at-Google. The thing is my code was copied from APIGEE doc before, the Raise Fault doc was changed too, now it is similar to what you suggested. I think APIGEE changed XML schema validation. I check today and my code works again. APIGEE might have fixed the error I guess.

Yes, it makes sense that Apigee changed the XML Schema validation.

But the doc... I will have to check on that. That seems unlikely. I don't think it ever worked that way.

@Will Witman or @sgilson - do you have any insight? Can you tell me if the RaiseFault doc previously showed an example policy like this?:

<RaiseFault name="xxx">
    <DisplayName>xxx</DisplayName>
    <Properties/>
    <FaultResponse>
        <Copy source="response">
            <Header/> <!-- this -->
            <Body/>   <!-- and this -->
        </Copy>
    </FaultResponse>
    <IgnoreUnresolvedVariables>true</IgnoreUnresolvedVariables>
</RaiseFault>

It looks like RaiseFault inherits the same Copy elements as AssignMessage, which means these:


  • <FormParams>
  • <Headers>
  • <Payload>
  • <Path>
  • <QueryParams>
  • <ReasonPhrase>
  • <StatusCode>
  • <Verb>
  • <Version>

I'll verify this and update the docs as needed.


Thanks @Will Witman , I do not find the code above in APIGEE docs anymore (no "Copy body" in Raise Fault). Do you think my code is deprecated and my wonder is that does APIGEE support backward compatibility ?

I'm sorry you're having trouble with RaiseFault. I checked back over four years and verified that the RaiseFault doc hasn't changed -- and I haven't found an example elsewhere like the one you shared above. Do you remember where you found it? I think fixing your code per the reference doc would be the best option.