我想将数据提供给一个代理,该代理创建一个SOAP XML请求,格式如下:
<dat:MusicCollection>
<!--Zero or more repetitions:-->
<dat:Song>
<dat:songUserkey>TakemeHome</dat:songUserkey>
</dat:Song>
</dat:MusicCollection>
我已经编写了文件来调用服务并提供如下详细信息:
dim ucizi1 as SongRequest 'this is the request class in the proxy
dim Songs as Song = New Song
Songs.songUserKey = "TakeMeHome"
dim ucz
ucz = Songs.SongUserKey
ucizi1.SongCollection.Add(ucz)
MusicCollection 类如下:
<System.Diagnostics.DebuggerStepThroughAttribute(), _
System.CodeDom.Compiler.GeneratedCodeAttribute("System.Runtime.Serialization", "4.0.0.0"), _
System.Runtime.Serialization.CollectionDataContractAttribute(Name:="ProductCollection", [Namespace]:="http://ucizi.Musicservice/DataContracts", ItemName:="Song")> _
Public Class SongCollection
Inherits System.Collections.Generic.List(Of ucizi.Music.DataContracts.Song)
End Class
歌曲类如下:
<System.Diagnostics.DebuggerStepThroughAttribute(), _
System.CodeDom.Compiler.GeneratedCodeAttribute("System.Runtime.Serialization", "4.0.0.0"), _
System.Runtime.Serialization.DataContractAttribute(Name:="Product", [Namespace]:="http://Ucizi.Music/DataContracts")> _
Partial Public Class Product
Inherits Object
Implements System.Runtime.Serialization.IExtensibleDataObject
Private extensionDataField As System.Runtime.Serialization.ExtensionDataObject
Private SongUserkeyField As String
Public Property ExtensionData() As System.Runtime.Serialization.ExtensionDataObject Implements System.Runtime.Serialization.IExtensibleDataObject.ExtensionData
Get
Return Me.extensionDataField
End Get
Set
Me.extensionDataField = value
End Set
End Property
<System.Runtime.Serialization.DataMemberAttribute(IsRequired:=true)> _
Public Property SongUserkey() As String
Get
Return Me.SongUserkeyField
End Get
Set
Me.SongUserkeyField = value
End Set
End Property
End Class
但是,当我运行此代码时,出现错误:无法将类型为“system.string”的对象转换为类型“ucizi.music.DataContracts.Song”。
我看不出这个错误是从哪里来的,有人可以帮助我并告诉我如何纠正这个错误。