【发布时间】:2021-07-05 07:20:41
【问题描述】:
我在反序列化 SOAP 响应时遇到问题。我得到像这样的xml: https://pastebin.com/pNFmJUzB 它来自网络服务的 xml
但 RegistryObjectList 中的元素未反序列化(statusField 已正确反序列化):
此代码是从 webService 提供者共享的 wsdl 生成的。我使用 svcutil 来实现它。这是我的代码:
我运行这个函数:
Public Function DocumentRegistry_RegistryStoredQuery(ByVal AdhocQueryRequest As AdhocQueryRequest) As AdhocQueryResponse
Dim inValue As DocumentRegistry_RegistryStoredQueryRequest = New DocumentRegistry_RegistryStoredQueryRequest()
inValue.AdhocQueryRequest = AdhocQueryRequest
Dim retVal As DocumentRegistry_RegistryStoredQueryResponse = CType(Me,ObslugaEdmIti18WSPortType).DocumentRegistry_RegistryStoredQuery(inValue)
Return retVal.AdhocQueryResponse
End Function
返回 AdHocQueryResponse :
'''<remarks/>
<System.CodeDom.Compiler.GeneratedCodeAttribute("svcutil", "4.8.3928.0"), _
System.SerializableAttribute(), _
System.Diagnostics.DebuggerStepThroughAttribute(), _
System.ComponentModel.DesignerCategoryAttribute("code"), _
System.Xml.Serialization.XmlTypeAttribute(AnonymousType:=true, [Namespace]:="urn:oasis:names:tc:ebxml-regrep:xsd:query:3.0")> _
Partial Public Class AdhocQueryResponse
Inherits RegistryResponseType
Private registryObjectListField() As IdentifiableType
Private startIndexField As String
Private totalResultCountField As String
Public Sub New()
MyBase.New
Me.startIndexField = "0"
End Sub
'''<remarks/>
<System.Xml.Serialization.XmlArrayAttribute(Order:=0), _
System.Xml.Serialization.XmlArrayItemAttribute("Identifiable", IsNullable:=False)> _
Public Property RegistryObjectList() As IdentifiableType()
Get
Return Me.registryObjectListField
End Get
Set(value As IdentifiableType())
Me.registryObjectListField = value
End Set
End Property
'''<remarks/>
<System.Xml.Serialization.XmlAttributeAttribute(DataType:="integer"), _
System.ComponentModel.DefaultValueAttribute("0")> _
Public Property startIndex() As String
Get
Return Me.startIndexField
End Get
Set
Me.startIndexField = value
End Set
End Property
'''<remarks/>
<System.Xml.Serialization.XmlAttributeAttribute(DataType:="integer")> _
Public Property totalResultCount() As String
Get
Return Me.totalResultCountField
End Get
Set
Me.totalResultCountField = value
End Set
End Property
End Class
AdHocQueryResponse 应该包含 ExtrinsicObjects :
'''<remarks/>
<System.Xml.Serialization.XmlIncludeAttribute(GetType(RegistryObjectType)), _
System.Xml.Serialization.XmlIncludeAttribute(GetType(NotificationType)), _
System.Xml.Serialization.XmlIncludeAttribute(GetType(AdhocQueryType)), _
System.Xml.Serialization.XmlIncludeAttribute(GetType(SubscriptionType)), _
System.Xml.Serialization.XmlIncludeAttribute(GetType(FederationType)), _
System.Xml.Serialization.XmlIncludeAttribute(GetType(RegistryType)), _
System.Xml.Serialization.XmlIncludeAttribute(GetType(PersonType)), _
System.Xml.Serialization.XmlIncludeAttribute(GetType(UserType)), _
System.Xml.Serialization.XmlIncludeAttribute(GetType(SpecificationLinkType)), _
System.Xml.Serialization.XmlIncludeAttribute(GetType(ServiceBindingType)), _
System.Xml.Serialization.XmlIncludeAttribute(GetType(ServiceType)), _
System.Xml.Serialization.XmlIncludeAttribute(GetType(RegistryPackageType)), _
System.Xml.Serialization.XmlIncludeAttribute(GetType(OrganizationType)), _
System.Xml.Serialization.XmlIncludeAttribute(GetType(ExtrinsicObjectType)), _
System.Xml.Serialization.XmlIncludeAttribute(GetType(ExternalLinkType)), _
System.Xml.Serialization.XmlIncludeAttribute(GetType(ClassificationSchemeType)), _
System.Xml.Serialization.XmlIncludeAttribute(GetType(ClassificationNodeType)), _
System.Xml.Serialization.XmlIncludeAttribute(GetType(AuditableEventType)), _
System.Xml.Serialization.XmlIncludeAttribute(GetType(AssociationType1)), _
System.Xml.Serialization.XmlIncludeAttribute(GetType(ExternalIdentifierType)), _
System.Xml.Serialization.XmlIncludeAttribute(GetType(ClassificationType)), _
System.Xml.Serialization.XmlIncludeAttribute(GetType(ObjectRefType)), _
System.CodeDom.Compiler.GeneratedCodeAttribute("svcutil", "4.8.3928.0"), _
System.SerializableAttribute(), _
System.Diagnostics.DebuggerStepThroughAttribute(), _
System.ComponentModel.DesignerCategoryAttribute("code"), _
System.Xml.Serialization.XmlTypeAttribute([Namespace]:="urn:oasis:names:tc:ebxml-regrep:xsd:rim:3.0")> _
Partial Public Class IdentifiableType
Private slotField() As SlotType1
Private idField As String
Private homeField As String
'''<remarks/>
<System.Xml.Serialization.XmlElementAttribute("Slot", Order:=0)> _
Public Property Slot() As SlotType1()
Get
Return Me.slotField
End Get
Set
Me.slotField = value
End Set
End Property
'''<remarks/>
<System.Xml.Serialization.XmlAttributeAttribute(DataType:="anyURI")> _
Public Property id() As String
Get
Return Me.idField
End Get
Set
Me.idField = value
End Set
End Property
'''<remarks/>
<System.Xml.Serialization.XmlAttributeAttribute(DataType:="anyURI")> _
Public Property home() As String
Get
Return Me.homeField
End Get
Set
Me.homeField = value
End Set
End Property
End Class
'''<remarks/>
<System.Xml.Serialization.XmlIncludeAttribute(GetType(NotificationType)), _
System.Xml.Serialization.XmlIncludeAttribute(GetType(AdhocQueryType)), _
System.Xml.Serialization.XmlIncludeAttribute(GetType(SubscriptionType)), _
System.Xml.Serialization.XmlIncludeAttribute(GetType(FederationType)), _
System.Xml.Serialization.XmlIncludeAttribute(GetType(RegistryType)), _
System.Xml.Serialization.XmlIncludeAttribute(GetType(PersonType)), _
System.Xml.Serialization.XmlIncludeAttribute(GetType(UserType)), _
System.Xml.Serialization.XmlIncludeAttribute(GetType(SpecificationLinkType)), _
System.Xml.Serialization.XmlIncludeAttribute(GetType(ServiceBindingType)), _
System.Xml.Serialization.XmlIncludeAttribute(GetType(ServiceType)), _
System.Xml.Serialization.XmlIncludeAttribute(GetType(RegistryPackageType)), _
System.Xml.Serialization.XmlIncludeAttribute(GetType(OrganizationType)), _
System.Xml.Serialization.XmlIncludeAttribute(GetType(ExtrinsicObjectType)), _
System.Xml.Serialization.XmlIncludeAttribute(GetType(ExternalLinkType)), _
System.Xml.Serialization.XmlIncludeAttribute(GetType(ClassificationSchemeType)), _
System.Xml.Serialization.XmlIncludeAttribute(GetType(ClassificationNodeType)), _
System.Xml.Serialization.XmlIncludeAttribute(GetType(AuditableEventType)), _
System.Xml.Serialization.XmlIncludeAttribute(GetType(AssociationType1)), _
System.Xml.Serialization.XmlIncludeAttribute(GetType(ExternalIdentifierType)), _
System.Xml.Serialization.XmlIncludeAttribute(GetType(ClassificationType)), _
System.CodeDom.Compiler.GeneratedCodeAttribute("svcutil", "4.8.3928.0"), _
System.SerializableAttribute(), _
System.Diagnostics.DebuggerStepThroughAttribute(), _
System.ComponentModel.DesignerCategoryAttribute("code"), _
System.Xml.Serialization.XmlTypeAttribute([Namespace]:="urn:oasis:names:tc:ebxml-regrep:xsd:rim:3.0")> _
Partial Public Class RegistryObjectType
Inherits IdentifiableType
Private nameField As InternationalStringType
Private descriptionField As InternationalStringType
Private versionInfoField As VersionInfoType
Private classificationField() As ClassificationType
Private externalIdentifierField() As ExternalIdentifierType
Private lidField As String
Private objectTypeField As String
Private statusField As String
'''<remarks/>
<System.Xml.Serialization.XmlElementAttribute(Order:=0)> _
Public Property Name() As InternationalStringType
Get
Return Me.nameField
End Get
Set
Me.nameField = value
End Set
End Property
'''<remarks/>
<System.Xml.Serialization.XmlElementAttribute(Order:=1)> _
Public Property Description() As InternationalStringType
Get
Return Me.descriptionField
End Get
Set
Me.descriptionField = value
End Set
End Property
'''<remarks/>
<System.Xml.Serialization.XmlElementAttribute(Order:=2)> _
Public Property VersionInfo() As VersionInfoType
Get
Return Me.versionInfoField
End Get
Set
Me.versionInfoField = value
End Set
End Property
'''<remarks/>
<System.Xml.Serialization.XmlElementAttribute("Classification", Order:=3)> _
Public Property Classification() As ClassificationType()
Get
Return Me.classificationField
End Get
Set
Me.classificationField = value
End Set
End Property
'''<remarks/>
<System.Xml.Serialization.XmlElementAttribute("ExternalIdentifier", Order:=4)> _
Public Property ExternalIdentifier() As ExternalIdentifierType()
Get
Return Me.externalIdentifierField
End Get
Set
Me.externalIdentifierField = value
End Set
End Property
'''<remarks/>
<System.Xml.Serialization.XmlAttributeAttribute(DataType:="anyURI")> _
Public Property lid() As String
Get
Return Me.lidField
End Get
Set
Me.lidField = value
End Set
End Property
'''<remarks/>
<System.Xml.Serialization.XmlAttributeAttribute(DataType:="anyURI")> _
Public Property objectType() As String
Get
Return Me.objectTypeField
End Get
Set
Me.objectTypeField = value
End Set
End Property
'''<remarks/>
<System.Xml.Serialization.XmlAttributeAttribute(DataType:="anyURI")> _
Public Property status() As String
Get
Return Me.statusField
End Get
Set
Me.statusField = value
End Set
End Property
End Class
我希望我分享了解决我的问题所需的所有代码。
【问题讨论】: