การแก้ปัญหาข้อผิดพลาดเกี่ยวกับรันไทม์ของนโยบายการตรวจสอบข้อความ SOAP

คุณกำลังดูเอกสารประกอบของ Apigee Edge
ไปที่เอกสารประกอบของ Apigee X
ข้อมูล

SourceMessageNotAvailable

รหัสข้อผิดพลาด

steps.messagevalidation.SourceMessageNotAvailable

เนื้อหาการตอบกลับข้อผิดพลาด

{
  "fault": {
    "faultstring": "source_var_name message is not
     available for[policy_name]",
    "detail": {
      "Errorcode":
       "steps.messagevalidation.SourceMessageNotAvailable"
     }
  }
}

ตัวอย่างเนื้อหาการตอบกลับข้อผิดพลาด

{
  "fault": {
    "faultstring": "request message is not available for MessageValidation: SOAP-Message-Validation-1",
    "detail": {
      "errorcode": "steps.messagevalidation.SourceMessageNotAvailable"
    }
  }
}

สาเหตุ

ข้อผิดพลาดนี้เกิดขึ้นหากตัวแปร message ที่ระบุในองค์ประกอบ <Source> ของนโยบาย SOAPMessageValidation มีลักษณะดังนี้

  • อยู่นอกขอบเขต (ใช้ไม่ได้ในขั้นตอนเฉพาะเจาะจงที่มีการใช้นโยบาย) หรือ
  • แก้ไขไม่ได้ (ไม่ได้กำหนด)

ตัวอย่างเช่น ข้อผิดพลาดนี้เกิดขึ้นหากมีการตั้งค่าองค์ประกอบ <Source> ในนโยบาย SOAPMessageValidation เป็นตัวแปรที่ไม่มีอยู่ในโฟลว์ที่มีการดำเนินการนโยบาย

การวินิจฉัย

  1. ระบุชื่อนโยบาย SOAPMessageValidation ที่เกิดข้อผิดพลาดและชื่อของตัวแปร source จากสตริงข้อผิดพลาด ตัวอย่างเช่น ในสตริงข้อผิดพลาดต่อไปนี้ ชื่อนโยบาย SOAPMessageValidation คือ SOAP-Message-Validation-1 และตัวแปร source คือ request

    "faultstring": "request message is not available for MessageValidation: SOAP-Message-Validation-1"
    
  2. ใน XML ของนโยบาย SOAPMessageValidation ที่ล้มเหลว ให้ตรวจสอบว่าชื่อของตัวแปรที่ตั้งค่าไว้ในองค์ประกอบ <Source> ตรงกับชื่อตัวแปรที่ระบุในสตริงข้อผิดพลาด (ขั้นตอนที่ 1 ด้านบน)

    ตัวอย่างเช่น นโยบาย SOAPMessageValidation จะระบุตัวแปรชื่อ request ในองค์ประกอบ <Source> ซึ่งตรงกับสิ่งที่อยู่ในสตริงข้อผิดพลาด

    <MessageValidation async="false" continueOnError="false" enabled="true" name="SOAP-Message-Validation-1">
        <DisplayName>SOAP Message Validation-1</DisplayName>
        <Properties/>
        <Element namespace="http://schemas.xmlsoap.org/soap/prices">GetPriceResponse</Element>
        <SOAPMessage/>
        <Source>request</Source>
        <ResourceURL>xsd://Script-1.xsd</ResourceURL>
    </MessageValidation>
    
  3. พิจารณาว่าตัวแปรที่ใช้ในองค์ประกอบ <Source> ได้รับการกำหนดและพร้อมใช้งานในโฟลว์ที่มีการดำเนินการนโยบาย SOAPMessageValidation หรือไม่

    กรณีที่ตัวแปรเป็นอย่างใดอย่างหนึ่งต่อไปนี้

    • อยู่นอกขอบเขต (ใช้ไม่ได้ในขั้นตอนเฉพาะเจาะจงที่มีการใช้นโยบาย) หรือ
    • แก้ไขไม่ได้ (ไม่ได้กำหนด)

    ก็จะเป็นสาเหตุของข้อผิดพลาด

    ตัวอย่างเช่น สมมติว่านโยบาย SOAPMessageValidation ที่แสดงด้านบนทำงานในขั้นตอนการตอบกลับ แต่ตัวแปร request ที่ใช้ในตัวอย่างองค์ประกอบ <Source> ด้านบนจะใช้ได้เฉพาะในขั้นตอนคําขอเท่านั้น

    เนื่องจากไม่มีตัวแปร request อยู่ในขั้นตอนการตอบสนอง คุณจึงได้รับข้อผิดพลาดต่อไปนี้

    "faultstring": "request message is not available for MessageValidation: SOAP-Message-Validation-1"
    

ความละเอียด

ตรวจสอบว่าได้กำหนดตัวแปรที่ตั้งค่าในเอลิเมนต์ <Source> ของนโยบาย SOAPMessageValidation ที่ล้มเหลวและอยู่ในโฟลว์ที่นโยบายใช้งาน

หากต้องการแก้ไขตัวอย่างที่แสดงข้างต้น ให้แก้ไของค์ประกอบ <Source> ให้ใช้ตัวแปร response ที่มีอยู่ในขั้นตอนการตอบสนอง ดังนี้

<MessageValidation async="false" continueOnError="false" enabled="true" name="SOAP-Message-Validation-1">
    <DisplayName>SOAP Message Validation-1</DisplayName>
    <Properties/>
    <Element namespace="http://schemas.xmlsoap.org/soap/prices">GetPriceResponse</Element>
    <SOAPMessage/>
    <Source>response</Source>
    <ResourceURL>xsd://Script-1.xsd</ResourceURL>
</MessageValidation>

NonMessageVariable

รหัสข้อผิดพลาด

steps.messagevalidation.NonMessageVariable

เนื้อหาการตอบกลับข้อผิดพลาด

{
  "fault": {
    "faultstring": "Variable var_name does not resolve to a Message"
    "detail": {
      "errorcode": "steps.messagevalidation.NonMessageVariable"
    }
  }
}

ตัวอย่างเนื้อหาการตอบกลับข้อผิดพลาด

{
  "fault": {
    "faultstring": "Variable message.content does not resolve to a Message",
    "detail": {
      "errorcode": "steps.messagevalidation.NonMessageVariable"
    }
  }
}

สาเหตุ

ข้อผิดพลาดนี้เกิดขึ้นหากมีการตั้งค่าองค์ประกอบ <Source> ในนโยบาย SOAPMessageValidation เป็นตัวแปรที่ไม่ใช่ประเภท Message

ตัวแปรประเภทข้อความจะเป็นตัวแทนของคำขอและการตอบกลับ HTTP ทั้งหมด ตัวแปรโฟลว์ Apigee Edge ในตัว request, response และ message เป็นประเภทข้อความ ดูข้อมูลเพิ่มเติมเกี่ยวกับตัวแปรข้อความได้ที่ข้อมูลอ้างอิงตัวแปร

การวินิจฉัย

  1. ระบุชื่อตัวแปรที่ไม่ได้แปลงให้เป็นประเภทข้อความจากสตริงข้อผิดพลาด ตัวอย่างเช่น ในสตริงข้อผิดพลาดต่อไปนี้ ชื่อของตัวแปรคือ message.content

    "faultstring": "Variable message.content does not resolve to a Message"
    
  2. ตรวจสอบนโยบาย SOAPMessageValidation ในพร็อกซี API เฉพาะที่เกิดข้อผิดพลาด โดยอาจมีนโยบาย SOAPMessageValidation ได้อย่างน้อย 1 รายการ ระบุนโยบาย SOAPMessageValidation ที่ตัวแปรที่ระบุในองค์ประกอบ <Source> ตรงกับชื่อตัวแปรที่ระบุในสตริงข้อผิดพลาด (ขั้นตอนที่ 1 ด้านบน)

    ตัวอย่างเช่น นโยบายต่อไปนี้ตั้งค่าองค์ประกอบ <Source> เป็นตัวแปรที่ชื่อ message.content ซึ่งตรงกับสิ่งที่อยู่ในสตริงข้อผิดพลาด

    <MessageValidation async="false" continueOnError="false" enabled="true" name="SOAP-Message-Validation-1">
        <DisplayName>SOAP Message Validation-1</DisplayName>
        <Properties/>
        <Element namespace="http://schemas.xmlsoap.org/soap/prices">GetPriceResponse</Element>
        <SOAPMessage/>
        <Source>message.content</Source>
        <ResourceURL>xsd://Script-1.xsd</ResourceURL>
    </MessageValidation>
    

    เนื่องจากตัวแปร message.content ไม่ใช่ประเภทข้อความ คุณจึงได้รับข้อผิดพลาด:

    "faultstring": "Variable message.content does not resolve to a Message"
    

ความละเอียด

ตรวจสอบว่าได้กำหนดองค์ประกอบ <Source> ในนโยบาย SOAPMessageValidation ที่ล้มเหลวเป็นตัวแปรประเภท Message ที่อยู่ในขั้นตอนที่มีการใช้นโยบาย

หากต้องการแก้ไขนโยบาย คุณสามารถแก้ไของค์ประกอบ <Source> เพื่อระบุตัวแปรที่เป็นประเภทข้อความได้ เช่น ในนโยบาย SOAPMessageValidation ที่ล้มเหลว คุณสามารถระบุองค์ประกอบ <Source> เป็น request

<MessageValidation async="false" continueOnError="false" enabled="true" name="SOAP-Message-Validation-1">
    <DisplayName>SOAP Message Validation-1</DisplayName>
    <Properties/>
    <Element namespace="http://sample.com"> sampleObject</Element>
    <SOAPMessage/>
    <Source>request</Source>
    <ResourceURL>xsd://Script-1.xsd</ResourceURL>
</MessageValidation>

ไม่สำเร็จ

รหัสข้อผิดพลาด

steps.messagevalidation.Failed

เนื้อหาการตอบกลับข้อผิดพลาด

{
  "fault": {
    "faultstring": "Variable var_name failed with reason: \"reason [Line varline_num
    "detail": {
      "errorcode": "steps.messagevalidation.Failed"
    }
  }
}

ตัวอย่างเนื้อหาการตอบกลับข้อผิดพลาด

{
  "fault": {
    "faultstring": "SOAP-Message-Validation-1 failed with reason: \"Expecting a child element but found none [Line 9]\"",
    "detail": {
      "errorcode": "steps.messagevalidation.Failed"
    }
  }
}

สาเหตุ

ข้อผิดพลาดนี้เกิดขึ้นหากนโยบาย SOAPMessageValidation ไม่สามารถยืนยันเพย์โหลดข้อความอินพุตกับสคีมา XSD หรือคำจำกัดความ WSDL นอกจากนี้จะเกิดขึ้นหากมี JSON หรือ XML ที่มีรูปแบบไม่ถูกต้องในข้อความเพย์โหลด

สาเหตุบางส่วนที่อาจทำให้เกิดข้อผิดพลาดนี้มีดังนี้

สาเหตุ คำอธิบาย
เพย์โหลด XML ไม่ตรงกัน เพย์โหลด XML ที่ป้อนไม่เป็นไปตามสคีมา XSD ที่ระบุไว้ในนโยบาย SoapMessageValidation
เพย์โหลด SOAP ไม่ตรงกัน เพย์โหลด SOAP ที่ป้อนไม่เป็นไปตามคำจำกัดความ WSDL ที่ระบุในนโยบาย SoapMessageValidation
JSON หรือ XML ที่มีรูปแบบไม่ถูกต้อง เพย์โหลด SOAP ที่ป้อนไม่มี XML หรือ JSON ที่มีรูปแบบถูกต้อง

สาเหตุ: เพย์โหลด XML ไม่ตรงกัน

ข้อผิดพลาดนี้เกิดขึ้นหากเพย์โหลด XML ของอินพุตไม่เป็นไปตามสคีมา XSD ที่ระบุไว้ในองค์ประกอบ <ResourceURL> ของนโยบาย SoapMessageValidation

ตัวอย่างข้อความแสดงข้อผิดพลาด

{
  "fault": {
    "faultstring": "SOAP-Message-Validation-1 failed with reason: \"Expecting a child element but found none [Line 9]\"",
    "detail": {
      "errorcode": "steps.messagevalidation.Failed"
    }
  }
}

การวินิจฉัย

  1. ระบุชื่อนโยบาย SOAPMessageValidation, สาเหตุของความล้มเหลว และหมายเลขบรรทัดที่เพย์โหลด XML ไม่ตรงกับสคีมา XSD ข้อมูลทั้งหมดนี้อยู่ในสตริงข้อผิดพลาด ตัวอย่างเช่น ในสตริงข้อผิดพลาดต่อไปนี้ ชื่อนโยบาย SOAPMessageValidation คือSOAP-Message-Validation-1,สาเหตุของความล้มเหลวคือ Expecting a child element but found none [Line 9] และหมายเลขบรรทัดคือ 9

    "faultstring": "SOAP-Message-Validation-1 failed with reason: \"Expecting a child element but found none [Line 9]\""
    
  2. ตรวจสอบนโยบาย SOAPMessageValidation และยืนยันว่ามีการใช้ไฟล์คำจำกัดความสคีมา XSD เพื่อตรวจสอบข้อความ ตัวอย่างเช่น นโยบาย SOAPMessageValidation ต่อไปนี้มีไฟล์ทรัพยากร XSD ในองค์ประกอบ <ResourceURL>

    <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <MessageValidation async="false" continueOnError="false" enabled="true" name="SOAP-Message-Validation-1">
        <DisplayName>SOAP Message Validation-1</DisplayName>
        <Properties/>
        <SOAPMessage/>
        <Source>request</Source>
        <ResourceURL>xsd://Script-1.xsd</ResourceURL>
    </MessageValidation>
    
  3. ตรวจสอบเพย์โหลดอินพุตบนหมายเลขบรรทัดที่ระบุไว้ในขั้นตอนที่ 1 ข้างต้น เพื่อทําความเข้าใจสาเหตุของความล้มเหลว

    ตัวอย่างเปย์โหลด XML อินพุต

    <?xml version="1.0"?>
    <soap:Envelope
    xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" soap:encodingStyle="http://www.w3.org/2003/05/soap-encoding">
    <soap:Body>
        <shipOrder
        xmlns:xsi="http://www.w3.org/2000/10/XMLSchema-instance">
        <shipTo>
            <name>Karl Kalckstein</name>
        </shipTo>
        <items>
            <item>
                <title>I love APIs</title>
                <quantity>1</quantity>
                <price>2.90</price>
            </item>
        </items>
    </shipOrder>
    </soap:Body>
    </soap:Envelope>
    

    ในตัวอย่างที่แสดงข้างต้น บรรทัดที่ 9 มีแท็กปิดท้าย </shipTo>

  4. ตรวจสอบไฟล์การกำหนดสคีมา XML Script-1.xsd ที่ใช้ในนโยบาย SOAPMessageValidation เพื่อดูว่าองค์ประกอบ <shipTo> ควรมีลักษณะอย่างไร

    ...
    <xsd:element name="shipTo" type="shipAddress"/>
    ...
    <xsd:complexType name="shipAddress">
    <xsd:sequence>
    <xsd:element name="name" type="xsd:string"/>
    <xsd:element name="street" type="xsd:string"/>
    <xsd:element name="address" type="xsd:string"/>
    <xsd:element name="country" type="xsd:string"/>
    </xsd:sequence>
    </xsd:complexType>
    ...
    

    ตาม XSD ตัวอย่างที่ใช้สำหรับการตรวจสอบ องค์ประกอบ <shipTo> ต้องมีองค์ประกอบย่อย <name>, <street>, <address> และ <country> แต่เพย์โหลด XML อินพุตมีองค์ประกอบย่อยเพียง 1 รายการ คือ <name> คุณจึงพบข้อผิดพลาดดังนี้

    "faultstring": "SOAP-Message-Validation-1 failed with reason: \"Expecting a child element but found none [Line 9]\""
    

ความละเอียด

คุณจะแก้ไขข้อผิดพลาดจากการตรวจสอบความถูกต้องได้ 2 วิธี ดังนี้

โซลูชันที่ 1

หากพบว่าคำจำกัดความสคีมา XSD กำหนดข้อจำกัดที่ไม่จำเป็น และต้องมีเฉพาะองค์ประกอบย่อย <name> เท่านั้นภายใต้องค์ประกอบ <shipTo> คุณจะแก้ไข Script-1.xsd ที่ใช้ในนโยบาย SOAPMessageValidation ได้ หากต้องการตรวจสอบตัวอย่างเพย์โหลดข้างต้น คุณสามารถแก้ไขไฟล์ XSD ได้ดังนี้

...
<xsd:element name="shipTo" type="shipAddress"/>
...
<xsd:complexType name="shipAddress">
<xsd:sequence>
<xsd:element name="name" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>

โซลูชันที่ 2

หากไฟล์คำจำกัดความ XSD ถูกต้อง จะเปลี่ยนเปย์โหลด XML ของอินพุตให้ตรงกับ xsd ได้ ตัวอย่างเช่น คุณอาจแก้ไขเพย์โหลดให้สอดคล้องกับ xsd ดังนี้

<?xml version="1.0">
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" soap:encodingStyle="http://www.w3.org/2003/05/soap-encoding">
<soap:Body>
    <shipOrder xmlns:xsi="http://www.w3.org/2000/10/XMLSchema-instance">
    <shipTo>
        <name>Karl Kalckstein</name>
        <street>1020 Parkway</street>
        <address>Mountain View, CA 94043</address>
        <country>USA</country>
    </shipTo>
    <items>
        <item>
            <title>I love APIs</title>
            <quantity>1</quantity>
            <price>2.90</price>
        </item>
    </items>
</shipOrder>
</soap:Body>
</soap:Envelope>

สาเหตุ: เพย์โหลด SOAP ไม่ตรงกัน

ข้อผิดพลาดนี้เกิดขึ้นหากเพย์โหลด SOAP อินพุตไม่เป็นไปตามคำจำกัดความ WSDL ที่ระบุไว้ในองค์ประกอบ <ResourceURL> ของนโยบาย SoapMessageValidation

ตัวอย่างข้อความแสดงข้อผิดพลาด

{
  "fault": {
    "faultstring": "SOAP-Message-Validation-1 failed with reason: \"Element name mismatch. Wildcard? [Line 11]\"",
    "detail": {
      "errorcode": "steps.messagevalidation.Failed"
    }
  }
}

การวินิจฉัย

  1. ระบุชื่อนโยบาย SOAPMessageValidation, สาเหตุของความล้มเหลว และหมายเลขบรรทัดที่เพย์โหลด SOAP ไม่ตรงกับคำจำกัดความ WSDL คุณสามารถดูข้อมูลทั้งหมดนี้ได้จากสตริง fault ตัวอย่างเช่น ในสตริงข้อผิดพลาดต่อไปนี้ ชื่อนโยบาย SOAPMessageValidation คือ SOAP-Message-Validation-1 สาเหตุของความล้มเหลวคือ \"Element name mismatch. Wildcard? [Line 11]\"" และหมายเลขบรรทัดคือ 11

    "faultstring": "SOAP-Message-Validation-1 failed with reason: \"Element name mismatch. Wildcard? [Line 11]\""
    
  2. ตรวจสอบนโยบาย SOAPMessageValidation และยืนยันว่ามีการใช้สคีมา wsdl เพื่อตรวจสอบข้อความ ตัวอย่างเช่น นโยบาย SOAPMessageValidation ต่อไปนี้มีไฟล์ทรัพยากร wsdl ในองค์ประกอบ <ResourceURL>

    <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <MessageValidation async="false" continueOnError="false" enabled="true" name="SOAP-Message-Validation-1">
        <DisplayName>SOAP Message Validation-1</DisplayName>
        <Properties/>
        <SOAPMessage/>
        <Source>request</Source>
     <ResourceURL>wsdl://SOAP-Message-Validation-1.wsdl</ResourceURL>
    </MessageValidation>
    
  3. ตรวจสอบเพย์โหลดอินพุตบนหมายเลขบรรทัดที่ระบุไว้ในขั้นตอนที่ 1 เพื่อทำความเข้าใจสาเหตุของความล้มเหลว

    ตัวอย่างเพย์โหลด SOAP อินพุต

    <?xml version="1.0"?>
    <soap:Envelope
    xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
    soap:encodingStyle="http://www.w3.org/2003/05/soap-encoding">
    <soap:Body>
    <shipOrder
    xmlns:xsi="http://www.w3.org/2000/10/XMLSchema-instance">
      <shipTo>
        <name>Karl Kalckstein</name>
        <street>1020 Parkway</street>
        <address>Mountain View, CA 94043</address>
        <country>USA</country>
      </shipTo>
      <items>
        <item>
          <title>I love APIs</title>
          <quantity>1</quantity>
          <price>2.90</price>
        </item>
      </items>
    

    ในตัวอย่างที่แสดงข้างต้น บรรทัดที่ 11 มีองค์ประกอบย่อย <country> อยู่ใต้องค์ประกอบ <shipTo>

  4. ตรวจสอบไฟล์คำจำกัดความ WSDL ชื่อ SOAP-Message-Validation-1.wsdl ซึ่งใช้ในนโยบาย SOAPMessageValidation เพื่อดูว่าเกิดอะไรขึ้นกับองค์ประกอบย่อย <country> ภายใต้องค์ประกอบ <shipTo>

    <?xml version="1.0" encoding="ISO-8859-1"?>
    <wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
        <wsdl:types>
          <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    <xsd:element name="shipOrder" type="order"/>
    <xsd:complexType name="order">
    <xsd:sequence>
    <xsd:element name="shipTo" type="shipAddress"/>
    <xsd:element name="items" type="cdItems"/>
    </xsd:sequence>
    </xsd:complexType>
    <xsd:complexType name="shipAddress">
    <xsd:sequence>
    <xsd:element name="name" type="xsd:string"/>
    <xsd:element name="street" type="xsd:string"/>
    <xsd:element name="address" type="xsd:string"/>
    </xsd:sequence>
    ...
    

    ตามคำจำกัดความของ WSDL ที่ใช้สำหรับการตรวจสอบ องค์ประกอบ <shipTo> ไม่มีองค์ประกอบย่อย <country> คุณจึงพบข้อผิดพลาดดังนี้

    "faultstring": "SOAP-Message-Validation-1 failed with reason: \"Element name mismatch. Wildcard? [Line 11]\""
    

ความละเอียด

คุณจะแก้ไขข้อผิดพลาดจากการตรวจสอบความถูกต้องได้ 2 วิธี ดังนี้

โซลูชันที่ 1

หากพิจารณาว่าคําจํากัดความ WSDL ที่ใช้นั้นไม่ถูกต้อง คุณจะเปลี่ยน SOAP-Message-Validation-1.wsdl ที่ใช้ในนโยบาย SOAPMessageValidation ได้ หากต้องการตรวจสอบตัวอย่างเพย์โหลดข้างต้น คุณสามารถแก้ไขไฟล์ได้ดังนี้

...
<xsd:complexType name="shipAddress">`
...
<sequence>
    <element name="name" type="xsd:string"/>
    <element name="street" type="xsd:string"/>
    <element name="address" type="xsd:string"/>
    <element name="country" type="xsd:string"/>
</sequence>

โซลูชันที่ 2

หากคําจํากัดความ WSDL ถูกต้อง คุณจะเปลี่ยนเพย์โหลด SOAP อินพุตให้ตรงกับคําจํากัดความของ WSDL ได้

ตัวอย่างเช่น คุณสามารถแก้ไขเพย์โหลด SOAP อินพุตได้ดังนี้

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<soap:Envelope
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
soap:encodingStyle="http://www.w3.org/2003/05/soap-encoding">
<soap:Body>
<shipOrder xmlns:xsi="http://www.w3.org/2000/10/XMLSchema-instance">
    <shipTo>
        <name>Karl Kalckstein</name>
        <street>1020 Parkway</street>
        <address>Mountain View, CA 94043</address>
    </shipTo>
    <items>
        <item>
            <title>I love APIs</title>
            <quantity>1</quantity>
            <price>2.90</price>
        </item>
    </items>

สาเหตุ: JSON หรือ XML ที่มีรูปแบบไม่ถูกต้อง

ข้อผิดพลาดนี้เกิดขึ้นหากเพย์โหลด SOAP อินพุตไม่เป็นไปตามคำจำกัดความ WSDL ที่ระบุไว้ในองค์ประกอบ <ResourceURL> ของนโยบาย SoapMessageValidation

ตัวอย่างข้อความแสดงข้อผิดพลาด

{
  "fault": {
    "faultstring": "SOAP-Message-Validation-1 failed with reason: \"Expected <\/title> at line 15(possibly  around char 420)\"",
    "detail": {
      "errorcode": "steps.messagevalidation.Failed"
    }
  }
}

การวินิจฉัย

  1. ระบุชื่อนโยบาย SOAPMessageValidation, สาเหตุของความล้มเหลว และหมายเลขบรรทัดของเพย์โหลด XML ที่ไม่ตรงกับคำจำกัดความ WSDL คุณสามารถดูข้อมูลทั้งหมดนี้ได้ในสตริง Fault ตัวอย่างเช่น ในสตริงข้อผิดพลาดต่อไปนี้ ชื่อนโยบาย SOAPMessageValidation คือ SOAP-Message-Validation-1 สาเหตุของความล้มเหลวคือ Expected </title> at line 15(possibly around char 420): และหมายเลขบรรทัดคือ 15.

    "faultstring": "SOAP-Message-Validation-1 failed with reason: \"Expected </title> at line 15(possibly  around char 420)\""
    
  2. ตรวจสอบเพย์โหลดอินพุตบนหมายเลขบรรทัดที่ระบุไว้ในขั้นตอนที่ 1 ข้างต้น เพื่อทําความเข้าใจสาเหตุของความล้มเหลว

    ตัวอย่างเพย์โหลด SOAP อินพุต

    <?xml version="1.0"?>
    <soap:Envelope
    xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
    soap:encodingStyle="http://www.w3.org/2003/05/soap-encoding">
    <soap:Body>
    <shipOrder xmlns:xsi="http://www.w3.org/2000/10/XMLSchema-instance">
      <shipTo>
        <name>Karl Kalckstein</name>
        <street>1020 Parkway</street>
        <address>Mountain View, CA 94043</address>
        <country>USA</country>
      </shipTo>
      <items>
        <item>
          <title>I love APIs</titles>
          <quantity>1</quantity>
          <price>2.90</price>
        </item>
      </items>
    </shipOrder>
    </soap:Body>
    </soap:Envelope>
    

    ในตัวอย่างที่แสดงข้างต้น บรรทัดที่ 15 ของ XML อินพุตมีองค์ประกอบ <title> แต่ไม่ได้ปิดด้วยแท็กปิดท้าย </title>

ความละเอียด

หากต้องการแก้ไขข้อผิดพลาด ให้ตรวจสอบว่าเพย์โหลดอินพุตถูกต้องและมีรูปแบบถูกต้อง

ตัวอย่างเช่น คุณอาจแก้ไขเพย์โหลด XML ของอินพุตดังนี้

...
</shipTo>
<items>
  <item>
    <title>I love APIs</title>
    <quantity>1</quantity>
    <price>2.90</price>
  </item>
</items>
...