我有一个 C# WCF REST 服务正在运行,它工作得很好而且很花哨。但是,在某些时候,我正在执行一个 PUT 请求来更新一个类。我发送到 WCF 服务的(修剪过的)JSON:
{
"admin": {
"EntityName": "TestAdmin_xCCg_edited",
"EntityParent": {
"TenantBankAccountNr": "1234567",
"TenantCity": "Amsterdam",
"TenantCountry": "Holland",
"TenantGroup": null,
"TenantNr": "1P",
"TenantPrefix": "MB",
"TenantStreet": "DeStraatStraat",
"TenantStreetNr": "38",
"TenantVatNr": "1234",
"TenantZipcode": "1442",
"AdSynced": false,
"CreatedByUser": null,
"CreationDate": "0001-01-01T00:00:00+01:00",
"EntityName": "Partner_NXfL",
"EntityParent": {
"AdSynced": false,
"CreatedByUser": "Unknown",
"CreationDate": "2013-02-13T15:59:28+01:00",
"EntityName": "Veliq",
"EntityParent": null,
"EntityType": 2,
"EntityUID": "172de253-b71d-44ef-ae52-94c21ca957ba",
"GroupMemberships": null,
"LazyProperties": [
"EntityParent",
"GroupMemberships"
],
"MappedIdentifier": null,
"MappedSystem": null,
"ModificationDate": "2013-02-13T15:59:28+01:00",
"ModifiedByUser": "Unknown"
},
"EntityType": 2,
"EntityUID": "2a15f1ea-fefb-408f-9c88-abcb392ad9c3",
"GroupMemberships": null,
"LazyProperties": [
"EntityParent",
"GroupMemberships",
"TenantGroup"
],
"MappedIdentifier": null,
"MappedSystem": null,
"ModificationDate": "0001-01-01T00:00:00+01:00",
"ModifiedByUser": null
},
"EntityType": 6,
"EntityUID": "70bc26fc-f50d-4e11-8b04-983b1c5978c0",
}
}
基本对象(WSAdmin 类型的“admin”对象)可以正常发送,但问题是 EntityParent 字段不是。它是 WSPartner 类型(它扩展了 WSTenant 扩展了 WSEntity),但是服务器接收到的数据是 WSEntity 类型的。这意味着它会截断许多它确实不应该截断的数据。我该如何解决这个问题?手动添加 "__type" : "WSPartner:#MOBIWS" 标志不起作用,它会引发有关 ServiceKnownType 等的异常。我已经添加了所有这些类型并且它们可以工作。
我还看到了一个关于空格给出错误的问题,但这对我来说不是问题(我发送的是非美化的 JSON)。任何帮助将非常感激!