views:

198

answers:

1

I am totally new to serialization and would greatly appreciate any help.

I am having problems deserializing the response message I receive from the proxy class I created through WSDL.exe. I believe the problem lies in the fact that I am using XmlArrayItem, which has nested items within.

Instead of getting:

<results xmlns="urn:partner.soap.company.com">
    <result>
        <created>false</created>
        <id>0018000000ZqV8DAAV</id>
        <success>true</success>
     </result>
     <result>
        <created>false</created>
        <id>0018000000ZqVMAAA3</id>
        <success>true</success>
     </result>
</results>

I am receiving the following in code:

created(0):false
id(0): false 0018000000ZqV8DAAV
success(0):false 0018000000ZqV8DAAVtrue

created(1):false 0018000000ZqV8DAAVtruefalse
id(1): false 0018000000ZqV8DAAVtruefalse0018000000ZqVMAAA3
success(1): false 0018000000ZqV8DAAVtruefalse0018000000ZqVMAAA3true

It appears as if the response just keeps appending the next part of the message without clearing out anything that has gone before.

Here is the main function that calls the web service:

 <System.Web.Services.Protocols.SoapDocumentMethodAttribute("", Use:=System.Web.Services.Description.SoapBindingUse.Literal, _
    ParameterStyle:=System.Web.Services.Protocols.SoapParameterStyle.Bare)> _
    Public Function Provide_Service(<System.Xml.Serialization.XmlElement([Namespace]:="http://www.company.com/connectors/request/129/")&gt; _
    ByVal USIUpdates As USIUpdates) As _
    <System.Xml.Serialization.XmlArray("results", IsNullable:=False, [Namespace]:="urn:partner.soap.sforce.com"), _
    System.Xml.Serialization.XmlArrayItem("result", IsNullable:=False)> UpsertResult()

        Dim results() As Object = Me.Invoke("Provide_Service", New Object() {USIUpdates})
        Return CType(results(0), UpsertResult())
    End Function

And here is the class the generates the response:

<System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.42"), _
 System.SerializableAttribute(), _
 System.Diagnostics.DebuggerStepThroughAttribute(), _
 System.ComponentModel.DesignerCategoryAttribute("code"), _
 System.Xml.Serialization.XmlTypeAttribute([Namespace]:="urn:partner.soap.company.com")> _
Partial Public Class UpsertResult

    'Public ReturnResponseItems As [ResponseItems]

    Private createdField As String

    Private errorsField() As [Error]

    Private idField As String

    Private successField As String

    '''<remarks/>
    Public Property created() As String
        Get
            Return Me.createdField
        End Get
        Set(ByVal value As String)
            Me.createdField = value
        End Set
    End Property

    '''<remarks/>
    <System.Xml.Serialization.XmlElementAttribute("errors")> _
    Public Property errors() As [Error]()
        Get
            Return Me.errorsField
        End Get
        Set(ByVal value As [Error]())
            Me.errorsField = value
        End Set
    End Property

    '''<remarks/>
    <XmlElementAttribute(isnullable:=True)> _
    Public Property id() As String
        Get
            Return Me.idField
        End Get
        Set(ByVal value As String)
            Me.idField = value
        End Set
    End Property

    '''<remarks/>
    Public Property success() As String
        Get
            Return Me.successField
        End Get
        Set(ByVal value As String)
            Me.successField = value
        End Set
    End Property
End Class

I would be grateful for any ideas or advice on how to handle this.

A: 

In case anyone else has this problem, here is the solution. For some reason when WSDL.exe was run, the XMLArrayItemAttribute did not properly point to the class containing the arrays within.

Thus, the following needed to be added to XMLArrayItemAttribute in the main function:

Type:=GetType(UpsertResult)

which then looks like this:

System.Xml.Serialization.XmlArrayItemAttribute("result", IsNullable:=False, Type:=GetType(UpsertResult))

Jimbo