0
私は2つのERPシステム間でデータを共有するWebサービスを開発中です。最初のERPは、データオブジェクトをシリアライズして2番目のERPに送信するWebサービスを呼び出します。xsiのXMLシリアライゼーション動作を制御する方法:nill =
<xs:complexType name="Parent">
<xs:sequence>
<xs:element ref="ta:ReceiptLine" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="Child">
<xs:sequence>
...
<xs:element name="SerialNo" type="xs:string" nillable="true" minOccurs="0"/>
<xs:element name="Quantity" type="xs:int" nillable="false"/>
...
</xs:sequence>
</xs:complexType>
...
<xs:element name="Child" type="ta:Child" nillable="true"/>
XSDによって生成されたクラス:
データオブジェクトは、次のようになり、私はXmlSerializerを
と私のデータオブジェクトをシリアライズしてい
[System.Serializable]
[System.Xml.Serialization.XmlTypeAttribute(Namespace="http://FSM4TA/DataObjects/")]
[System.Xml.Serialization.XmlRootAttribute(Namespace="http://FSM4TA/DataObjects/", IsNullable=false)]
public partial class Parent {
private Child[] child;
[System.Xml.Serialization.XmlElementAttribute("Child", IsNullable=true)]
public Child[] Child {
get {return this.child;}
set {this.child = value;}
}
[System.Serializable]
[System.Xml.Serialization.XmlTypeAttribute(Namespace="http://FSM4TA/DataObjects/")]
[System.Xml.Serialization.XmlRootAttribute(Namespace="http://FSM4TA/DataObjects/", IsNullable=true)]
public partial class Child{
private string serialNo;
private int quantity;
[System.Xml.Serialization.XmlElementAttribute(IsNullable=true)]
public string SerialNo {
get {return this.serialNo;}
set {this.serialNo = value;}
}
public int Quantity {
get { return this.quantity;}
set {this.quantity = value;}
}
}
問題です: (直列化時)Childオブジェクトが空の場合(xsi:nil = "true")、XSDはたびにChild構造全体を生成します。数量がnillableではないため、および/ NULL可能XSDは次のように...値として書き込み:
は<Parent>
</Child xsi:nil="true">
</Parent>
質問です:
<Parent>
<Child xsi:nil="true">
<SerialNo xsi:nil="true" />
<Quantity>0</Quantity>
</Child>
</Parent>
私はこのような何かを得ることが期待されていますXSDがxsi:nil = "true"を解析するのを防ぐ方法がありますか?
提案がありますか?
TIA
あなたの答えはここにあるhttp://social.msdn.microsoft.com/Forums/en-US/wcf/thread/430972b0 -40a6-41f9-9590-57cfceb9a0e3?prof =必須 –