Question Seeing List Of as 1D Array

Joined
Oct 6, 2011
Messages
1
Location
Johannesburg, Gauteng, South Africa
Programming Experience
Beginner
Hi

This is post #1 for me - apologies if it's in the wrong forum.

I have deployed a web service that I would now like to test. I have created a class thus:

VB.NET:
Public Class FulfilmentOrder


        Public Unique_Ref As String
        Public Invoice_Number As String
        Public Order_Date As String
        Public Delivery_Instructions1 As String
        Public Delivery_Instructions2 As String
        Public Number_of_Items As String
        Public DeliveryDate As String
        [B]Public orderItems As List(Of OrderItem)   'This is the problem item[/B]
        Public timestamp As String
        Public Customer As CustomerDetails


End Class

The class has been included in both the web service and my test Windows form app.

For some reason, when I try this in my test form:

VB.NET:
Dim Item As New WHITServe.OrderItem
Dim TempList As New List(Of WHITServe.OrderItem)

        Item.Item_Code = "655"
        Item.Item_Description = "Book"
        Item.Qty = "10"
        Item.Price = "100"
        Item.Discount = "0"
        Item.PreOrder = False


        TempList.Add(Item)


       [B] Order.orderItems = TempList[/B]

I get "Value of type 'System.Collections.Generic.List(Of TestEdconWebService.WHITServe.OrderItem)' cannot be converted to '1-dimensional array of TestEdconWebService.WHITServe.OrderItem'."

So the list that's declared in the test form is seen as a list, but it's seeing the list in the web service as an array :uncomfortableness:
 
Does this:
The class has been included in both the web service and my test Windows form app.
mean that you have the same class definition in two different projects or that you have declared the class in a library project and referenced that from the other two?
 
The class has been included in both the web service and my test Windows form app.
That is unnessary as you should be using the proxy types generated when you added web reference.
the list that's declared in the test form is seen as a list, but it's seeing the list in the web service as an array
A web service (by its wdsl) has no conception of .Net generics or any .Net type for that matter, everything gets turned to primitive and complex types that can be described by the xml definitions. Unbounded reoccuring elements is seen as arrays.
I get "Value of type 'System.Collections.Generic.List(Of TestEdconWebService.WHITServe.OrderItem)' cannot be converted to '1-dimensional array of TestEdconWebService.WHITServe.OrderItem'."
You can still create and use a dynamic list in your client code and use its ToArray method when assigning it to the proxy object.

As far as .Net development is concerned web services is outdated technology, you should be looking at WCF services now.
 
Back
Top