SoapUI 对序列架构断言是否过于严格?

问题描述

问题

我正在使用请求和后续响应中的附加可选字段扩展现有的 SOAP 函数调用我希望这是一个不间断的更改,因此已将该字段移至现有序列的末尾。

但是,在使用 SoapUI 中的现有架构测试“架构合规性”时,此新元素的断言失败并显示“元素不允许...”。

我是真的引入了重大更改,还是 SoapUI 在这里过于严格?

参考代码

这是我的原始 WSDL(用于回复,精简版):

 <xs:schema elementFormDefault="qualified" targetNamespace="http://schemas.datacontract.org/2004/07/..." xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://schemas.datacontract.org/2004/07/...">
     <xs:complexType name="mutation">
        <xs:sequence>
           <xs:element minOccurs="0" name="addressLine1" nillable="true" type="xs:string"/>
           //...
           <xs:element minOccurs="0" name="town" nillable="true" type="xs:string"/>
        </xs:sequence>
     </xs:complexType>
     <xs:element name="mutation" nillable="true" type="tns:mutation"/>
  </xs:schema>

这是我的新 WSDL(用于响应,压缩)(请注意,新的 UID 值出现在序列中最后一个先前存在的元素之后):

<xs:schema elementFormDefault="qualified" targetNamespace="http://schemas.datacontract.org/2004/07/..." xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://schemas.datacontract.org/2004/07/...">
    <xs:complexType name="mutation">
        <xs:sequence>
            <xs:element minOccurs="0" name="addressLine1" nillable="true" type="xs:string"/>
            //...
            <xs:element minOccurs="0" name="town" nillable="true" type="xs:string"/>
            <xs:element minOccurs="0" name="uid" nillable="true" type="tns:uid"/>
        </xs:sequence>
    </xs:complexType>
    <xs:element name="mutation" nillable="true" type="tns:mutation"/>
    <xs:complexType name="uid">
        <xs:sequence>
            <xs:element minOccurs="0" name="uidOrganisationId" nillable="true" type="xs:int"/>
            <xs:element minOccurs="0" name="uidOrganisationIdCategorie" nillable="true" type="xs:string"/>
        </xs:sequence>
    </xs:complexType>
    <xs:element name="uid" nillable="true" type="tns:uid"/>
</xs:schema>

这是新回复的示例(精简版)

<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:a="http://www.w3.org/2005/08/addressing">
   <s:Header>
      <a:Action s:mustUnderstand="1">http://.../GetMutationResponse</a:Action>
      <ActivityId CorrelationId="eaa2fb0d-0e9d-4237-909e-db025b6d7d74" xmlns="http://schemas.microsoft.com/2004/09/ServiceModel/Diagnostics">00000000-0000-0000-0000-000000000000</ActivityId>
   </s:Header>
   <s:Body>
      <GetMutationResponse xmlns="http://.../">
         <GetMutationResult xmlns:b="http://schemas.datacontract.org/2004/07/..." xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
            <b:addressLine1 i:nil="true"/>
            //...
            <b:town>Couvet</b:town>
            <b:uid i:nil="true"/>
         </GetMutationResult>
      </GetMutationResponse>
   </s:Body>
</s:Envelope>

我曾预料到,“架构合规性”断言会忽略序列中的附加属性。但是我得到

com.eviware.soapui.impl.wsdl.teststeps.assertions.basic.SchemaComplianceAssertion@1b1aa6e3
line 32: Element not allowed: uid@http://schemas.datacontract.org/2004/07/... in element GetMutationResult@http://.../

注意事项:

我已经阅读了 https://stackoverflow.com/a/20414654 并且我相信我已经绕过了那里讨论的问题。

上下文:这是一个 WCF Web 服务,在类上具有 [Datacontract] 属性

这是类定义(精简):

[DataContract(Name = "mutation")]
[Serializable]
[XmlRoot("mutation")]
[XmlType("mutation")]
public class MutationExtern {
    private UidExternV1X8 _uid;

    // other properties
    
    [DataMember(Name = "uid",Isrequired = false)]
    [XmlElement(ElementName = "uid",IsNullable = true)]
    public UidExternV1X8 Uid
    {
        get => _uid;
        set => _uid = value;
    }
    //....
}

服务调用返回此类的序列化实例。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)