使用Web服务Xml.Serialization.XmlArrayItemAttribute

时间:2016-11-21 21:05:24

标签: .net vb.net web-services xml-serialization xmlserializer

我正在尝试将我的请求发送到WSDL中定义的TestList方法:

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

我已将我的列表创建为TestItem_Type,并且我在此对象中拥有所有客户端数据:

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

WSDLCall.SendList = MyList

此时MyList存在问题。

“类型'myref.TestItem_Type'的值无法转换为'myref.TestItem_Type'的一维数组

我是否需要序列化列表,因为Web服务大纲使用System.Xml.Serialization.XmlArrayItemAttribute?我已经尝试将MyList声明为数组,但没有运气。

1 个答案:

答案 0 :(得分:1)

您已将TestList声明为数组

.text-block {

BASIC .text-block STYLES

}

.slide .text-block {

ADDITIONAL .slide .text-block STYLES

}

.slide--current .text-block {

ADDITIONAL .slide--current .text-block STYLES

}

然后使用单个项目调用它(即使您将其标记为列表)

Public TestList() As myref.TestItem_Type

所以传入一个数组:(假设你的版本支持这种语法)

Dim MyList As New myref.TestItem_Type
MyList.sNumber = 1
MyList.bdentifier = 21
WSDLCall.SendList = MyList
相关问题