好的,我终于弄清楚了,这与调用方法之前的序列化有关。我重写了传入该方法的类,因此它不需要 XMLElement 作为属性,因此不需要预序列化的类,并将其传入。这工作正常,只需要 3 或 4 周的工作.. .如果有人想要更多澄清,我可以尝试在这里得到它。
编辑:回应约翰桑德斯的评论。当我说预序列化时,我的意思是包含字节数组的类在通过 web 方法发送之前被序列化为 XML。这是因为在 web 方法中发送的类只接受一个 XMLElement。我重新设计了该类,即 web 方法的参数,以接受另一个类,而无需事先序列化为 XML。
IE。这就是班级现在的样子。添加并使用了字段和属性,而processRepairOrder
不是PRO()
anyField
Partial Public Class Content
Private anyField As System.Xml.XmlElement
Private idField As String
Private anyAttrField() As System.Xml.XmlAttribute
'This was added
Private processRepairOrder As ProcessRepairOrder
'This was added
'''<remarks/>
<System.Xml.Serialization.XmlElementAttribute([ElementName]:="ProcessRepairOrder", [Namespace]:="http://www.starstandards.org/STAR")> _
Public Property PRO() As ProcessRepairOrder
Get
Return Me.processRepairOrder
End Get
Set(ByVal value As ProcessRepairOrder)
Me.processRepairOrder = value
End Set
End Property
'''<remarks/>
<System.Xml.Serialization.XmlAnyElementAttribute()> _
Public Property Any() As System.Xml.XmlElement
Get
Return Me.anyField
End Get
Set(ByVal value As System.Xml.XmlElement)
Me.anyField = value
End Set
End Property
'''<remarks/>
<System.Xml.Serialization.XmlAttributeAttribute(DataType:="token")> _
Public Property id() As String
Get
Return Me.idField
End Get
Set(ByVal value As String)
Me.idField = value
End Set
End Property
'''<remarks/>
<System.Xml.Serialization.XmlAnyAttributeAttribute()> _
Public Property AnyAttr() As System.Xml.XmlAttribute()
Get
Return Me.anyAttrField
End Get
Set(ByVal value As System.Xml.XmlAttribute())
Me.anyAttrField = value
End Set
End Property
End Class
关于特定的命名空间,我们在所需的类中添加了另一个字段,如下所示:
<System.Xml.Serialization.XmlNamespaceDeclarations()> _
Public xmlns As XmlSerializerNamespaces
然后我们可以使用以下方法添加命名空间:
Dim ns As New Serialization.XmlSerializerNamespaces
ns.Add("s", "http://whatever")
class.xmlns = ns