2017-03-01 8 views
1

現時点では、現在稼働中の古い石鹸サービスを複製しようとしています。契約、要求、応答は正確にでなければなりません。このサービスを使用しているすべての依存システムを更新する必要はありません。この古い石鹸サービスのことは、回答の一つがかなり奇妙なことです。WCFレスポンス - レスポンスでリストをシリアライズ

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> 

<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が作る私のコードに次のような構造を考えて:それは以下の構造を有します

ご覧のとおり、元のsoapレスポンスと私のレプリケーションの違いは、FirstNameLastNameの前にPersondataタグです。私の意見ではこれは正しい構造ですが、前に述べたように、私は全く同じ方法でレスポンスを複製する必要があります...

元のレスポンスと同じ構造を作りたいのですが?私自身のシリアライザを書く必要がありますか?プロパティをマークすることができる属性はありますか?

ありがとうございます。

答えて

1

この種の問題に悩まされている方にお勧めします。あなたの財産に次の属性を追加します。

[MessageBodyMember(Namespace = "Some namespace"), XmlElement] 

最終結果:

public class GetInfo 
{ 
    public string IdNumber {get; set;} 

    [MessageBodyMember(Namespace = "Some namespace"), XmlElement] 
    public PersonData[] PersondataList {get; set;} 
} 
関連する問題