watsocd
asked on
Access a variant array of objects
I am working with web services and SOAP. I am trying to get my get my web service to return a complex type (an array).
Here is my simplified code:
'************************* ********** ********** **
DIM myvar as variant
If IsEmpty(temp) Then MsgBox "EMPTY"
myvar=MyWebServiceCall 'This is a function that returns an array of some type
If IsArray(temp) Then MsgBox "array"
MsgBox TypeName(temp)
MsgBox UBound(myvar)
'************************* ********** ********** **
I get the first msgbox indicating that myvar is empty.
I get the second msgbox indicating that myvar contains an array.
I get the third msgbox indicating: Object()
The program crashes on the last msgbox with a "Subscript out of range" error.
myvar should contain an array of objects that are of a userdefined type.
How do I get access to the array inside myvar?
Chuck
Here is my simplified code:
'*************************
DIM myvar as variant
If IsEmpty(temp) Then MsgBox "EMPTY"
myvar=MyWebServiceCall 'This is a function that returns an array of some type
If IsArray(temp) Then MsgBox "array"
MsgBox TypeName(temp)
MsgBox UBound(myvar)
'*************************
I get the first msgbox indicating that myvar is empty.
I get the second msgbox indicating that myvar contains an array.
I get the third msgbox indicating: Object()
The program crashes on the last msgbox with a "Subscript out of range" error.
myvar should contain an array of objects that are of a userdefined type.
How do I get access to the array inside myvar?
Chuck
You're code is a little confusing. Where does "temp" come into all of this ? You are checking that "temp" is an array, but you are trying to treat "myvar" as an array, so where does "temp" come from ?
ASKER
Sorry, I copied the code out of my original. The temp variable should be myvar.
Here is my corrected code:
'************************* ********** ********** **
DIM myvar as variant
If IsEmpty(myvar) Then MsgBox "EMPTY"
myvar=MyWebServiceCall() 'This is a function that returns an array of some type
If IsArray(myvar) Then MsgBox "array"
MsgBox TypeName(myvar)
MsgBox UBound(myvar)
'************************* ********** ********** **
Here is my corrected code:
'*************************
DIM myvar as variant
If IsEmpty(myvar) Then MsgBox "EMPTY"
myvar=MyWebServiceCall() 'This is a function that returns an array of some type
If IsArray(myvar) Then MsgBox "array"
MsgBox TypeName(myvar)
MsgBox UBound(myvar)
'*************************
ASKER
I am going to requres this question be deleted.
The problem was with the server, not the client.
I used proxyTrace to determine this by looking at the raw XML SOAP package.
Chuck
The problem was with the server, not the client.
I used proxyTrace to determine this by looking at the raw XML SOAP package.
Chuck
ASKER
Please PAQ and refund. I answered my own question.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.