1
我試圖複製一箇舊的soap服務,此服務正在生產中。合同,請求和響應必須是確切相同,所以我們不需要更新所有使用此服務的依賴系統。這個舊的soap服務的事情是,其中一個反應很奇怪。它具有以下結構:WCF響應 - 響應中的列表序列化
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns="http://something" xmlns:ns1="http://something1">
<soap:Body>
<ns:MyResponse>
<ns:GetInfo>
<ns1:IdNumber>12345</ns:IdNumber>
<ns1:PersondataList>
<ns1:FirstName>John</ns1:FirstName>
<ns1:LastName>Travolta</ns1:LastName>
</ns1:PersondataList>
</ns:GetInfo>
</ns:MyResponse>
</soap:Body>
</soap:envelope>
這immiditaly讓我在代碼思維以下結構:
public class GetInfo
{
public string IdNumber {get; set;}
public PersonData[] PersondataList {get; set;}
}
public class PersonData
{
public string FirstName {get; set;}
public string LastName {get; set;}
}
當了SoapUI測試這一點,我的回答如下:
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns="http://something" xmlns:ns1="http://something1">
<soap:Body>
<ns:MyResponse>
<ns:GetInfo>
<ns1:IdNumber>12345</ns:IdNumber>
<ns1:PersondataList>
<ns1:Persondata>
<ns1:FirstName>John</ns1:FirstName>
<ns1:LastName>Travolta</ns1:LastName>
<ns1:Persondata>
</ns1:PersondataList>
</ns:GetInfo>
</ns:MyResponse>
</soap:Body>
</soap:envelope>
如您所見,原始肥皂響應和我的複製之間的區別是FirstName
和LastName
之前的Persondata
標記。我認爲這是正確的結構,但如前所述,我需要以完全相同的方式複製響應...
如何生成與原始響應相同的結構?我是否需要編寫自己的序列化程序?有沒有可以標記我的屬性的屬性?
在此先感謝。