今朝私のWCF参照で奇妙な問題に遭遇しました。簡単に言えば、デュプレックスサービスをセットアップして、サーバがデータ契約でオブジェクトを送信してクライアントに通知できるようにします。クライアントが接続すると、サーバー上の関数が実行され、サービスクラスの共有キューにある内容に基づいてList(Of NewItem)
が返されます。問題は、クライアントでサービス参照を更新すると、List(Of NewItem)
オブジェクトではなく、NewItem
オブジェクトが返されることです。私は参照に移動して手動でそれをList
オブジェクトに変更することができます。それは正常に転送されます。サービス参照ジェネレータが返すタイプを任意に変更する理由は何ですか?wcfの参照が正しく生成されていない
ここに関連するコードです:
<ServiceContract(
CallbackContract:=GetType(INotifyCallback),
SessionMode:=ServiceModel.SessionMode.Required)>
Public Interface INotifyService
<OperationContract()>
Function GetNewServerItems() As List(Of NewItem)
End Interface
<DataContract>
<Serializable>
Public Class NewItem
<DataMember()>
Public Property ItemNum As String
<DataMember()>
Public Property Timestamp As DateTime
End Class
<ServiceBehavior(
ConcurrencyMode:=ServiceModel.ConcurrencyMode.Single,
InstanceContextMode:=ServiceModel.InstanceContextMode.Single)>
Public Class NotifyService
Implements INotifyService
Shared _server_items As New List(Of NewItem)
Public Function GetNewServerItems() As List(Of NewItem)
Return _server_items
End Function
End Class
とReference.vb(簡体字)で:
<System.ServiceModel.OperationContractAttribute(Action:="http://tempuri.org/INotifyService/GetNewServerItems", ReplyAction:="http://tempuri.org/INotifyService/GetNewServerItemsResponse")> _
Function GetNewServerItems() As NotifyGateway.NewItem()
プロジェクトを右クリックし、[サービス参照の追加]を選択して参照を追加しましたか? –
あなたは ''を忘れたのですか? –
@Gabobcat - はい。 – mounty