Warm tip: This article is reproduced from serverfault.com, please click

Extra element in the server soap response

发布于 2020-09-30 05:36:55

I have a wsdl schema. I am generating an answer with a class that contains a list of objects in one of the fields

<s:element name="ClassOfResponse">
    <s:complexType>
        <s:sequence>
            <s:element minOccurs="0" maxOccurs="1" name="ClassOfResponse" type="tns:ValueOfResponse"/>
        </s:sequence>
    </s:complexType>
</s:element>
<s:complexType name="ValueOfResponse">
    <s:sequence>
        <s:element minOccurs="1" maxOccurs="1" name="code" type="s:int"/>
        <s:element minOccurs="0" maxOccurs="1" name="message" type="s:string"/>
        <s:element minOccurs="0" maxOccurs="1" name="listValues" type="tns:ArrayOfValues"/>
    </s:sequence>
</s:complexType>
<s:complexType name="ArrayOfValues">
    <s:sequence>
        <s:element minOccurs="0" maxOccurs="unbounded" name="Value" nillable="true" type="tns:Value"/>
    </s:sequence>
</s:complexType>
<s:complexType name="Value">
    <s:sequence>
        <s:element minOccurs="1" maxOccurs="1" name="FieldA" type="s:string"/>
        <s:element minOccurs="1" maxOccurs="1" name="FieldB" type="s:string"/>
    </s:sequence>
</s:complexType>

During operation, my controller generates just such a response structure, it is such a structure that is required to receive in the response

{
    "ClassOfResponse": {
        "code":0,
        "message":"Consulta Exitosa",
        "listValues": [
            {
                "FieldA": "text A",
                "FieldB": "text B"
            },
            {
                "FieldA": "text A2",
                "FieldB": "text B2"
            },
        ]
    }
}

the client's soap response contains an extra element Value. I'm trying to understand how he got here and where is the error in the scheme

+"ClassOfResponse": {#617
    +"code": 0
    +"message": "Consulta Exitosa"
    +"listValues": {#618
        +"Value": array:2 [
            0 => {#619
                +"FieldA": "text A"
                +"FieldB": "text B"
            }
            1 => {#620
                +"FieldA": "text A2"
                +"FieldB": "text B2"
            }
        ]
    }
}

where does the intermediate Value come from?

Questioner
Takamura
Viewed
0
Takamura 2020-12-01 17:22:57

Typical behavior of a SOAP scheme with multiple data in a field is an array of classes

+"ClassOfResponse": {#617
    +"code": 0
    +"message": "Consulta Exitosa"
    +"listValues": {#618
        +"Value": array:2 [
            0 => {#619
                +"FieldA": "text A"
                +"FieldB": "text B"
            }
            1 => {#620
                +"FieldA": "text A2"
                +"FieldB": "text B2"
            }
        ]
    }
}

...with individual data in a field is the class

+"ClassOfResponse": {#617
    +"code": 0
    +"message": "Consulta Exitosa"
    +"listValues": {#618
        +"Value": {#619
           +"FieldA": "text A"
           +"FieldB": "text B"
        }
    }
}

This behavior is regulated by the schema. An unexpected twist to be honest