函数在我的WFC服务和客户端中返回的问题

时间:2016-03-03 15:01:52

标签: c# asp.net

我在我的客户端中定义了许多函数,作为示例

[OperationContract]
List<CustomObject> GetObject(string id);

尝试从我的界面调用此函数时尝试:

List<CustomObject> result = cvs.GetObject(5);我收到了错误,而我必须做的是CustomObject[] result = cvs.GetObject(5);

另一个例子是我定义一条消息:

[MessageContract]
public class TestRequest
{
     [MessageBodyMember]
     public Int64 Id;

     [MessageBodyMember]
     public int row;
}

和我的界面的功能:

[OperationContract]
ResponseMessage GetMessage(TestRequest req);

当我尝试以同样的方式使用它时:

TestRequest req = new TestRequest();
req.Id = 2;
req.row = 1;
ResponseMessage resp = cvs.GetMessage(req);

我收到了there is no overload for method that takes one argument消息。

以下是

创建的参考文件的相关部分
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
ResponseMessage MyService.GetMessage(TestRequest request)
{
    return base.Channel.GetMessage(request);
}

    public string GetMessage(long Id, int row, out long Length, out string Message, out System.IO.MemoryStream ReportMemoryStream)
    {
        TestRequest inValue = new ResponseMessage();
        inValue.Id = Id;
        inValue.row= row;
        ResponseMessage retVal = ((MyService)(this)).GetMessage(inValue);
        Length = retVal.Length;
        Message = retVal.Message;
        ReportMemoryStream = retVal.ReportMemoryStream;
        return retVal.FileName;
    }

为什么会发生客户端和wfc服务之间的脱节,我该如何解决呢。

2 个答案:

答案 0 :(得分:2)

这里有一个问题已经有一些答案可以解释客户端和服务之间的“断开连接”:

Why does WCF return myObject[] instead of List like I was expecting?

希望这就是你所追求的。

答案 1 :(得分:2)

您在上次更改方法后是否更新了服务引用? 看起来他生成的代理不是最新的。