简体   繁体   English

WCF服务数据合同的最后一个属性未添加

[英]wcf service datacontract last property not added

I'm adding a property to my model with an enum. 我正在用枚举将属性添加到模型中。

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
}

In my form I Create a ChildCareCentreEntryReservation object: 在我的表单中,我创建一个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;

I add the ChildCareCentreEntryReservation object to a list: 我将ChildCareCentreEntryReservation对象添加到列表中:

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

Then I send an array to the service by calling the function LockBasketItems: 然后,我通过调用函数LockBasketItems将数组发送到服务:

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

Everything builds and works correctly but my service doesn't receive my last added property. 一切都可以正常构建和运行,但是我的服务没有收到我最后添加的属性。

Fiddler inspectors result (client request to service): 提琴手检查员的结果(客户要求维修):

  <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>

Fiddler inspectors result (service response to client): 提琴手检查员的结果(对客户的服务响应):

  <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>

In my Reference.cs i'm seeing the property is correctly added. 在我的Reference.cs中,我看到该属性已正确添加。

Any idea what i am missing? 任何想法我想念的吗?

I'm using ASP.NET 我正在使用ASP.NET

Solution

I had to set ChildCareCentreEntryReservationStatusTypeSpecified to true 我必须将ChildCareCentreEntryReservationStatusTypeSpecified设置为true

 reservation.ChildCareCentreEntryReservationStatusTypeSpecified = true;

Solved 解决了

I had to set ChildCareCentreEntryReservationStatusTypeSpecified to true 我必须将ChildCareCentreEntryReservationStatusTypeSpecified设置为true

reservation.ChildCareCentreEntryReservationStatusTypeSpecified = true;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM