Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Web Services Variant Return Type

Status
Not open for further replies.

trScott

Technical User
Dec 13, 2004
31
0
0
US
We are calling a web service and the web service returns an array of strings (in a Variant data type). We cannot determine how to convert the variant into a usable data type. Has anybody done anything similar?
 
If the service returns an array of strings, why not return it as an array of strings? One of the main benefits of web services is the ability to access them from other systems. By returning a Variant you are effectively making your web service a VB6/A - only tool.

Now that I'm off my soap box though, how are you trying to call this service at the moment?

[small]----signature below----[/small]
You can't fit a square data in a round table

My Crummy Web Page
 
the web service returns an array of strings (in a Variant data type)
So what does the web service method return, an array of strings or an array of variants? It's got to be one or the other.

We cannot determine how to convert the variant into a usable data type.
What data type would be "usable" for you?

If you need a string, use CStr.
If you need an integer, use CInt.

etc.


 
Our web service is not returning a variant - that is how access interprets a complex type. Below is a snippet of the web service call from access (using a Microsoft tool to generate):

'Proxy function
'
'"wsm_ValidateAllTansferForPartnership" is an array with elements defined as String
'See Complex Types: Arrays in Microsoft Office 2003 Web Services Toolkit Help
'for details on implementing arrays.
'*****************************************************************

'Error Trap
On Error GoTo wsm_ValidateAllTransfersForPartnershipTrap

wsm_ValidateAllTransfersForPartnership = sc_Transfers.ValidateAllTransfersForPartnership(lng_partnershipId)

The web service is returning an array of strings.

We finally figured out what was actually in the variant. An array with one element. The one element inside the array is a String array. The following code shows how we looped through it (some of the display details are omitted):

results = ws.wsm_ValidateAllTransfersForPartnership(CLng([Forms]![frmMain]![lstK1s]))

If Not (IsEmpty(results)) Then

messages = Array(results)

For i = LBound(messages) To UBound(messages)

For Each varItem In messages

If Not (IsEmpty(varItem)) Then

For j = LBound(varItem) To UBound(varItem)

If (j = 0) Then
showMessages = (varItem(j) <> "0")
End If


Next

End If

Next varItem

Next

End If
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top