:生成されたクラスのWCF SerializableAttribute DataContractAttribute XmlTypeAttribute Xsd.exeではツール
xsd /c file1.xsd File2.xsd
一つは、私はWCF、のためのすべての生成されたクラスを使用したい
[System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "4.0.30319.1")]
[System.SerializableAttribute()] //please note here
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
//please note here
[System.Xml.Serialization.XmlTypeAttribute(AnonymousType = true, Namespace = "http://www.xx.com/xx")]
public partial class SelfEmploymentTypePartner
{
private string nameField;
private SelfEmploymentTypePartnerAddress addressField;
/// <remarks/>
public string Name
{
get { return this.nameField; }
set { this.nameField = value; }
}
/// <remarks/>
public SelfEmploymentTypePartnerAddress Address
{
get { return this.addressField; }
set { this.addressField = value; }
}
}
私はクラスとそのメンバーに DataContractAttribute、およびDataMemeberAttributeを追加する必要があります:以下のよう?以下のように:
[System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "2.0.50727.1432")]
[System.SerializableAttribute()] //please note here
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
//please note here
[System.Xml.Serialization.XmlTypeAttribute(AnonymousType = true,
Namespace ="urn:corexx:Application")]
[DataContract(Name = "SelfEmploymentTypePartner")] //please note here
public partial class SelfEmploymentTypePartner
{
private string nameField;
private SelfEmploymentTypePartnerAddress addressField;
/// <remarks/>
[DataMember]
public string Name
{
get
{
return this.nameField;
}
set
{
this.nameField = value;
}
}
/// <remarks/>
[DataMember]
public SelfEmploymentTypePartnerAddress Address
{
get
{
return this.addressField;
}
set
{
this.addressField = value;
}
}
}
既存のライブバージョンは、バージョン1を使用しているので、私はバージョン2に変更した場合は、は、それが現在のユーザー破るだろうか?
私がする必要がある場合は、は簡単な方法ですそれを行うには。私は何千ものコード行を編集する必要があるからです。
インターフェースは以下である:OperationContractとXmlSerializerFormat両方が一つが使用されるインターフェイス、ために使用される
[ServiceContract(SessionMode = SessionMode.Allowed, Namespace = "http://www.xxx.com" ,ProtectionLevel=ProtectionLevel.None)]
[WsdlDocumentation("")]
public interface IService
{
[OperationContract(ProtectionLevel= ProtectionLevel.None)] //please note here
[XmlSerializerFormat] //please note here
[FaultContract(typeof(ErrorDetailsStructure))]
MyResponse GetInfo(RequestParameter parameter);
}
。。 WCFはDataContractSerializerの代わりにXmlSerializerを使用しますか?
データコントラクトを生成する場合は、xsd.exeを使用しないでください。これは古いXMLシリアライザ技術の一部です。代わりにsvcutil.exeを使用してください。 –
ありがとう!代わりにsvcutil.exeを使用する理由がありますか? xsd.exeは廃止されますか?またはsvcutilexe WCFの方が良いでしょうか? – Pingpong
svcutil.exeはWCF用です。単にxsd.exeを使わないでください。 「廃止予定」は合法的な用語ですが、「使用しない」とは真実です。 –