【发布时间】:2011-09-15 20:25:31
【问题描述】:
我通常可以创建一个名为 SalesItem 的类的实例,并将其作为参数传递给 Web 服务,就像 webService.CreateSalesitem(New SalesItem()) 这样工作正常。
然后我将我的SalesItem 类子类化。我称它为GP_Item_SIM_Product。但是,当我尝试将此类作为参数传递给我的 Web 服务时,出现异常。 webService.CreateSalesitem(new GP_Item_SIM_Product())
这是一个例外:
尝试序列化参数时出错 http://schemas.microsoft.com/dynamics/gp/2010/01:salesItem。这 InnerException 消息是带有数据的“类型 'IMS.GP_Item_SIM_Product' 合同名称 'GP_Item_SIM_Product:http://schemas.datacontract.org/2004/07/IMS' 是 没想到。考虑使用 DataContractResolver 或添加任何类型 在已知类型列表中静态未知 - 例如,通过 使用 KnownTypeAttribute 属性或将它们添加到列表中 传递给 DataContractSerializer 的已知类型。请参见 InnerException 了解更多详情。
这是我的子类:
Imports System.ServiceModel
Imports GP_1.DynamicsGPClient
Imports GP_1.Microsoft.Dynamics.GP
Imports GP_1.Microsoft.Dynamics.Common
Imports SierraLib
Imports GP_1.GP
Imports GP_1
Imports System.Runtime.Serialization
< DataContract() > _
Public Class GP_Item_SIM_Product
Inherits SalesItem
Dim SIMProduct As Products
Dim greatPlainsRunner As GPRunner
Public Sub New(ByVal gpr As GPRunner, ByVal product As Products)
SIMProduct = product
greatPlainsRunner = gpr
SetValues()
End Sub
Private Sub SetValues()
Me.Key = New ItemKey() With {.Id = SIMProduct.MFGPN}
Me.Description = Description
Me.CurrentCost = New MoneyAmount() With {.Currency = Defaults.usCurrency, .Value = CDec(SIMProduct.Cost)}
Me.StandardCost = New MoneyAmount() With {.Currency = Defaults.usCurrency, .Value = CDec(SIMProduct.Price)}
Me.IsDiscontinued = Not SIMProduct.Enabled
Me.SalesTaxBasis = IIf(CBool(SIMProduct.Taxed = True),
GP_1.Microsoft.Dynamics.GP.SalesTaxBasis.Taxable,
GP_1.Microsoft.Dynamics.GP.SalesTaxBasis.Nontaxable)
End Sub
End Class
关于如何修改我的类以便将其发送到 Web 服务的任何想法。我认为这与我添加的此类中的两个字段有关。不确定我是否需要将它们标记为特殊的。
【问题讨论】:
标签: .net vb.net wcf web-services