SOAP请求错误…为什么我得到NRE?

| 我几乎从API PDF复制并粘贴了代码,但是在行上得到了一个N​​ull引用异常:
AccountArray(0) = AccountToUpdate
有人知道我在做什么错吗?谢谢!
Dim boolQueryFinished = False
Dim strCurrentID As String = \"0\"
Dim contractid As Integer
Dim strWebURI As String = \"https://webservices.autotask.net/atservices/1.5/atws.asmx\"
Dim myService As New ATWS
myService.Url = strWebURI
Dim cred As New System.Net.NetworkCredential(\"U\", \"P\")
Dim credCache As New System.Net.CredentialCache
credCache.Add(New Uri(myService.Url), \"Basic\", cred)
myService.Credentials = credCache
Dim AccountID As New ArrayList
Dim i As Integer
While Not (boolQueryFinished)
Dim strQuery As String = \"<queryxml><entity>Contract</entity>\" & _
\"<query><condition><field>id<expression op=\"\"greaterthan\"\">\" & strCurrentID &
\"</expression></field></condition></query>\" & _
\"</queryxml>\"
Dim r As ATWSResponse
r = myService.query(strQuery)
If r.EntityResults.Length > 0 Then
    For Each ent As Entity In r.EntityResults 
        strCurrentID = ent.id
        AccountID.Add(CType(ent, Contract).AccountID)

    Next
Else
    boolQueryFinished = True
    While i < ContractName.Count
        listOutput.Items.Add(ContractName(i))
        listOutput.Items.Add(id(i))
        If ContractName(i).Contains(\"Georges\") Then
            listOutput.Items.Add(\"Found it\")
            Dim sResponse As ATWSResponse
            Dim AccountToUpdate As New Contract
            Dim AccountArray(0) As Contract
            AccountToUpdate.AccountID = AccountID(i)


            AccountArray(0) = AccountToUpdate
            Dim entityArray() As Entity = CType(AccountArray, Entity())
            sResponse = myService.update(entityArray)

            If sResponse.ReturnCode = 1 Then
                listOutput.Items.Add(\"Updated\")
            Else
                listOutput.Items.Add(\"Failed\")

            End If
        End If

        i = i + 1
    End While
    listOutput.Items.Add(id.Count)
    listOutput.Items.Add(ContractName.Count)
End If
End While
    
已邀请:
看起来:
r.EntityResults.Length
不大于零。您已经进入了“ 3”子句。 进入了
While i < ContractName.Count
循环(尽管不清楚this5ѭ是什么。
i
尚未初始化,因此它的值是
0
。 从上面发布的内容中,我们应该看到一个ѭ8,因为我们正试图到达一个空ArrayList的索引0。     AccountToUpdate.AccountID = AccountID(i) 您确定要在
Else
块中包含
While
循环吗?我很好奇ѭ11陈述在哪里?     

要回复问题请先登录注册