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

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

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 อินพุตมีองค์ประกอบย่อย <name> เพียง 1 รายการ คุณจึงได้รับข้อผิดพลาด

    "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 คุณสามารถดูข้อมูลทั้งหมดนี้จากสตริงข้อผิดพลาด ตัวอย่างเช่น ในสตริงข้อผิดพลาดต่อไปนี้ ชื่อนโยบาย 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 คุณสามารถดูข้อมูลทั้งหมดนี้ได้ในสตริงข้อผิดพลาด ตัวอย่างเช่น ในสตริงข้อผิดพลาดต่อไปนี้ ชื่อนโยบาย 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>
...