levis84 levis84 - 15 days ago 6
Vb.net Question

Consuming web service Xml.Serialization.XmlArrayItemAttribute

I am trying to send my request in to this TestList method defined in the WSDL:

<System.ServiceModel.MessageBodyMemberAttribute([Namespace]:="[service url here]", Order:=8), _
System.Xml.Serialization.XmlArrayItemAttribute("TestItem", IsNullable:=false)>
Public TestList() As myref.TestItem_Type


I have created my list as TestItem_Type, and I have all the client data in this object:

Dim MyList As New myref.TestItem_Type
MyList.sNumber = 1
MyList.bdentifier = 21

WSDLCall.SendList = MyList


There is an issue with MyList at this point.

"Value of type 'myref.TestItem_Type' cannot be converted to '1-dimensional array of myref.TestItem_Type'

Do I need to serialise the list given that the web service outline uses System.Xml.Serialization.XmlArrayItemAttribute? I have tried declaring MyList as an array but no luck.

Answer

You have declared TestList as an array

Public TestList() As myref.TestItem_Type

You then call it using a single item (even though you mislabel it as a list)

Dim MyList As New myref.TestItem_Type
MyList.sNumber = 1
MyList.bdentifier = 21
WSDLCall.SendList = MyList

So pass in an array: (assuming your version supports this syntax)

WSDLCall.SendList = {MyList}