簡體   English   中英

WCF服務數據合同的最后一個屬性未添加

[英]wcf service datacontract last property not added

我正在用枚舉將屬性添加到模型中。

public class ChildCareCentreEntryReservation : BasketItem, ILockableBasketItem
{
      ....
    [DataMember]
    public ChildCareCentreEntryReservationStatusTypes ChildCareCentreEntryReservationStatusType { get; set; }
}

[DataContract(Namespace = Constants.Namespace)]
public enum ChildCareCentreEntryReservationStatusTypes
{
    [EnumMember]
    VoorlopigIngeschreven = 0,
    [EnumMember]
    DefinitiefIngeschreven = 1,
    [EnumMember]
    Geannuleerd = 2
}

在我的表單中,我創建一個ChildCareCentreEntryReservation對象:

  var reservation = new ChildCareCentreEntryReservation();
  reservation.ChildCareEntryPeriodId = _entryPeriod.Id;
  reservation.ChildCareCentreId = _centre.Id;
  reservation.PersonId = _person.Id;
  reservation.Comment = txtComment.Text;
  reservation.ChildCareCentreEntryReservationStatusType = (ChildCareCentreEntryReservationStatusTypes)cboStatusName.SelectedIndex;

我將ChildCareCentreEntryReservation對象添加到列表中:

var basketItems = new List<BasketItem> { reservation };

然后,我通過調用函數LockBasketItems將數組發送到服務:

 LockBasketResult lockBasketResult = Service.LockBasketItems(basketItems.ToArray(), Context);

一切都可以正常構建和運行,但是我的服務沒有收到我最后添加的屬性。

提琴手檢查員的結果(客戶要求維修):

  <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
    <s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<BasketItems xmlns="http://www./">
  <BasketItem xsi:type="ChildCareCentreEntryReservation">
    <RuleNamesToIgnore xsi:nil="true"/>
    <ChildCareEntryPeriodId>13ccefb3-f1e4-4f64-8fb8-b07cf30d2fca</ChildCareEntryPeriodId>
    <ChildCareCentreId>8cc85f37-da5d-46c5-9bb4-d6efa8448176</ChildCareCentreId>
    <PersonId>56e341bb-ac05-40dc-a39a-082ae4ff087e</PersonId>
    <ChildCareCentrePeriodIds>
      <guid xmlns="http://schemas.microsoft.com/2003/10/Serialization/Arrays">61c43967-8781-4d83-a117-963c5734491f</guid>
    </ChildCareCentrePeriodIds>
    <LockTicket xsi:nil="true"/>
    <Comment/>
    <PeriodOptions xsi:nil="true"/>
  </BasketItem>
</BasketItems>
<Context xmlns="http://www./">
  <Language>NL</Language>
  <ShopId>00000000-0000-0000-0000-000000000550</ShopId>
  <SessionId>de824345-14f3-44c7-99fd-f9a073e9b51b</SessionId>
</Context>

提琴手檢查員的結果(對客戶的服務響應):

  <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
    <s:Header>
  <ActivityId CorrelationId="d1daee11-20e2-4e98-8774-9bffe4e2e4f3" xmlns="http://schemas.microsoft.com/2004/09/ServiceModel/Diagnostics">728e68a9-17ff-44a0-b4ad-f455f403be5e</ActivityId>
    </s:Header>
    <s:Body>
      <LockBasketResult xmlns="http://www./" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
        <BasketItems>
    <BasketItem i:type="ChildCareCentreEntryReservation">
      <DivisionId>00000000-0000-0000-0000-000000000000</DivisionId>
      <Id>00000000-0000-0000-0000-000000000000</Id>
      <Quantity>1</Quantity>
      <RuleNamesToIgnore xmlns:a="http://schemas.microsoft.com/2003/10/Serialization/Arrays"/>
      <UnitPrice>0</UnitPrice>
      <ChildCareEntryPeriodId>13ccefb3-f1e4-4f64-8fb8-b07cf30d2fca</ChildCareEntryPeriodId>
      <ChildCareCentreId>8cc85f37-da5d-46c5-9bb4-d6efa8448176</ChildCareCentreId>
      <PersonId>56e341bb-ac05-40dc-a39a-082ae4ff087e</PersonId>
      <ChildCareCentrePeriodIds xmlns:a="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
        <a:guid>61c43967-8781-4d83-a117-963c5734491f</a:guid>
      </ChildCareCentrePeriodIds>
      <LockTicket i:type="ChildCareCentreEntryReservationLockTicket">
        <ExpirationTime>2013-10-08T17:27:06</ExpirationTime>
        <Id>13a984f8-5d97-4f87-aa52-7523849cc6f5</Id>
      </LockTicket>
      <Comment/>
      <PeriodOptions xmlns:a="http://schemas.datacontract.org/"/>
      <ChildCareCentreEntryReservationStatusType>VoorlopigIngeschreven</ChildCareCentreEntryReservationStatusType>
    </BasketItem>
  </BasketItems>
  <IsLocked>true</IsLocked>
  <ValidationResult i:nil="true"/>
</LockBasketResult>

在我的Reference.cs中,我看到該屬性已正確添加。

任何想法我想念的嗎?

我正在使用ASP.NET

我必須將ChildCareCentreEntryReservationStatusTypeSpecified設置為true

 reservation.ChildCareCentreEntryReservationStatusTypeSpecified = true;

解決了

我必須將ChildCareCentreEntryReservationStatusTypeSpecified設置為true

reservation.ChildCareCentreEntryReservationStatusTypeSpecified = true;

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM