使用网络服务 Xml.Serialization.XmlArrayItemAttribute
Consuming web service Xml.Serialization.XmlArrayItemAttribute
我正在尝试将我的请求发送到 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 声明为数组,但没有成功。
您已将 TestList 声明为数组
Public TestList() As myref.TestItem_Type
然后您使用单个项目调用它(即使您错误地将其标记为列表)
Dim MyList As New myref.TestItem_Type
MyList.sNumber = 1
MyList.bdentifier = 21
WSDLCall.SendList = MyList
所以传入一个数组:(假设你的版本支持这种语法)
WSDLCall.SendList = {MyList}
我正在尝试将我的请求发送到 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 声明为数组,但没有成功。
您已将 TestList 声明为数组
Public TestList() As myref.TestItem_Type
然后您使用单个项目调用它(即使您错误地将其标记为列表)
Dim MyList As New myref.TestItem_Type
MyList.sNumber = 1
MyList.bdentifier = 21
WSDLCall.SendList = MyList
所以传入一个数组:(假设你的版本支持这种语法)
WSDLCall.SendList = {MyList}