פתרון בעיות בהטמעה של מדיניות מ-XML ל-JSON

אתם צופים במסמכי התיעוד של Apigee Edge.
כדאי לעיין במסמכי התיעוד של Apigee X.
מידע

EitherOptionOrFormat

הודעת שגיאה

פריסת ה-proxy ל-API דרך ממשק המשתמש של Edge או Edge management API נכשלת עם הודעת השגיאה הבאה:

Error Saving Revision [revision_number]
XMLToJSON[{0}]: Either Options or Format must be specified.

שגיאה לדוגמה

Error Saving Revision 1
XMLToJSON[{0}]: Either Options or Format must be specified.

צילום מסך לדוגמה

סיבה

אם אחד מהרכיבים <Options> או <Format> לא מוצהר במדיניות XML ל-JSON, הפריסה של proxy ל-API נכשלת.

המאפיין <Options> הוא חובה אם לא משתמשים במאפיין <Format>.

אפשר להשתמש ברכיב <Format> או בקבוצת הרכיבים <Options>. אי אפשר להשתמש גם ב-<Format> וגם ב-<Options>. פורמטים מוגדרים מראש כוללים: xml.com,‏ yahoo,‏ google ו-badgerFish.

אבחון

  1. בודקים את כל כללי המדיניות של XML ל-JSON בשרת ה-proxy הספציפי של ה-API שבו אירע הכשל. אם יש מדיניות XML ל-JSON שבה לא מוצהר על אחד מהרכיבים <Options> או <Format>, זו הסיבה לשגיאה.

    לדוגמה, במדיניות הבאה לא מוצהר על אף אחד מהאלמנטים:

    <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <XMLToJSON async="false" continueOnError="false" enabled="true" name="XMLToJSON">
        <DisplayName>XMLToJSON</DisplayName>
        <Properties/>
        <OutputVariable>response</OutputVariable>
        <Source>response</Source>
    </XMLToJSON>
    

רזולוציה

מוודאים שקובץ ה-XML של מדיניות XML ל-JSON כולל את אחד הרכיבים <Options> או <Format> שמוצהרים במדיניות.

דוגמה 1:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<XMLToJSON async="false" continueOnError="false" enabled="true" name="XMLToJSON">
    <DisplayName>XMLToJSON</DisplayName>
    <Properties/>
    <Format>google</Format>
    <OutputVariable>response</OutputVariable>
    <Source>response</Source>
</XMLToJSON>

דוגמה 2:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<XMLToJSON async="false" continueOnError="false" enabled="true" name="XMLToJSON">
    <DisplayName>XMLToJSON</DisplayName>
    <Properties/>
    <Options>
        <RecognizeNumber>true</RecognizeNumber>
        <RecognizeBoolean>true</RecognizeBoolean>
        <RecognizeNull>true</RecognizeNull>
    </Options>
    <OutputVariable>response</OutputVariable>
    <Source>response</Source>
</XMLToJSON>

UnknownFormat

הודעת שגיאה

פריסת ה-proxy ל-API דרך ממשק המשתמש של Edge או Edge management API נכשלת עם הודעת השגיאה הבאה:

Error Saving Revision [revision_number]
XMLToJSON[policy_name]: Unknown Format [unknown_format].

שגיאה לדוגמה

Error Saving Revision 1
XMLToJSON[WithFormat]: Unknown Format google.com.

צילום מסך לדוגמה

סיבה

אם מוגדר פורמט לא ידוע לרכיב <Format> במדיניות XML ל-JSON, הפריסה של proxy ל-API נכשלת.

פורמטים מוגדרים מראש כוללים: xml.com,‏ yahoo,‏ google ו-badgerFish.

אבחון

  1. מזהים את מדיניות ה-XML ל-JSON שבה אירעה השגיאה ואת הפורמט הלא מוכר. אפשר למצוא את המידע הזה בהודעת השגיאה. לדוגמה, בשגיאה הבאה, שם המדיניות הוא WithFormat והפורמט הלא ידוע הוא google.com:

    Error Saving Revision 1
    XMLToJSON[WithFormat]: Unknown Format google.com.
    
  2. מוודאים שהפורמט הלא ידוע שצוין במדיניות XML ל-JSON שנכשלה זהה לערך שזוהה בהודעת השגיאה (שלב 1 למעלה). לדוגמה, המדיניות הבאה מציינת את הפורמט google.com, שזהה לפורמט שמופיע בהודעת השגיאה:

    <XMLToJSON async="false" continueOnError="false" enabled="true" name="WithFormat">
      <DisplayName>WithFormat</DisplayName>
      <Properties/>
      <Format>google.com</Format>
      <OutputVariable>response</OutputVariable>
      <Source>response</Source>
    </XMLToJSON>
    
  3. אם הפורמט שצוין לא נכלל בפורמטים המוגדרים מראש xml.com, yahoo, google או badgerFish, זו הסיבה לשגיאה.

    בדוגמה של מדיניות XML ל-JSON שמוצגת למעלה, הפורמט הוא google.com, שהוא לא תקין. לכן, פריסת ה-API Proxy נכשלת עם השגיאה:

    XMLToJSON[WithFormat]: Unknown Format google.com.
    

רזולוציה

צריך לוודא שהפורמט שצוין ברכיב <Format> של מדיניות XML ל-JSON תקין. לדוגמה:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<XMLToJSON async="false" continueOnError="false" enabled="true" name="WithFormat">
  <DisplayName>WithFormat</DisplayName>
  <Properties/>
  <Format>google</Format>
  <OutputVariable>response</OutputVariable>
  <Source>response</Source>
</XMLToJSON>