1

次のxmlスキーマを出力するために.net wcf webserviceを実行しています。(以下のシーマは一例です)

**<CarListOutput>
    <CarList>
      <Car>
        <Make />
        <Model /> 
        <Year />
      </Car>
      <Car>
        <Make />
        <Model /> 
        <Year />
      </Car>
    </CarList>
    <ExceptionList>
       <CustomError>
         <type />
         <errorMessage/>
       </CustomError>  
    </ExceptionList>      
</CarListOutput>**

「Car」(および「CustomError」)用の独自のクラスがあり、戻りオブジェクト「car list」(および「CustomError list」)にも正しいデータが用意されています。このオブジェクトを xml 文字列または XElement に個別にシリアル化できます (車のリストとカスタム エラー リスト)。私の質問は、オブジェクトを上記のxmlと同じに変換するにはどうすればよいですか? クライアントは特定のxml(正確な名前)を期待しているため、上記のxmlと同じことをしたいです。どんな助けでも素晴らしいでしょう。

4

1 に答える 1

0

create a class CarListOutput with datamember CarList and exceptionList, let your operation contact return CarListOutput type object. For further control on CarListOutput XML format use XmlSerializerFormat. You can read more on XmlSerializer at http://msdn.microsoft.com/en-us/library/ms733901.aspx

于 2012-06-27T17:51:46.960 に答える