0

wcf 自己ホスト型サービスを作成しています。UriTemplate クラスを使用して、URL をメソッドにカスタマイズしています。コードスニペットを以下に示します

 public interface ISelfService
    {
        [WebInvoke(Method = "POST", UriTemplate = "ack/{errorcode}/{uniquefileid}")]
        [OperationContract]
        void Ack(ErrorCode errorcode, string uniquefileid);

       [WebInvoke(Method = "POST", UriTemplate = "filechanged/{metainfo}")]
       [OperationContract]
       void FileChanged(MetaInformation metainfo);

     }

このプログラムを実行するたびに、次のエラーが発生します

コントラクト 'ISelfHostService' の操作 'FileChanged' には、タイプ 'Natash.Common.MetaInformation' の 'metainfo' という名前のクエリ変数がありますが、タイプ 'Natash.Common.MetaInformation' は 'QueryStringConverter' で変換できません。UriTemplate クエリ値の変数には、「QueryStringConverter」で変換できる型が必要です

なぜこれが起こっているのか誰にでも教えてもらえますか?

また、web.config ファイルに変更を加えていません。そこに変更を加える必要がありますか?

メタ情報は次のように定義されます

[DataContract]
    public struct MetaInformation
    {
        [DataMember]
        public string Author { get; set; }
        [DataMember]
        public string tags { get; set; }
        [DataMember]
        public string categories { get; set; }
        [DataMember]
        public string description { get; set; }
}
4

2 に答える 2

1

これを試して

public interface ISelfService{

    [OperationContract]
    [WebInvoke(Method = "POST", UriTemplate = "/ack?errorcode={errorcode}&uniquefileid={uniquefileid}")]
    void Ack(ErrorCode errorcode, string uniquefileid);

    [OperationContract]
    [WebInvoke(Method = "POST", UriTemplate = "/filechanged")]
    void FileChanged(MetaInformation metainfo);}

于 2012-12-12T08:26:58.193 に答える
0

投稿したメッセージから、MetaInformation クラス ( Gettrix.Common.MetaInformation& Natash.Common.MetaInformation) には 2 つの定義があるように聞こえます。

サービスをインスタンス化するときに、両方が WCF の範囲内にある可能性があります。もしそうなら、DataContract 属性を持たないもの (おそらくNatash.Common.MetaInformation) はあなたが参照しているものであり、したがってサービス内のデータ転送には使用できないと考えるかもしれません。

于 2012-12-11T17:54:26.050 に答える