使用ServiceClient参数使用WCF

时间:2014-06-15 02:35:06

标签: c# wcf

我有一个WCF服务,我试图像这样使用它

ServiceReference.ServiceClient service = new ServiceReference.ServiceClient(); service.function("Parameter1", "Parameter2");

但是当我调试时,我发现两个参数都是

ServiceName.ObjectId

我无法做任何事情。我实际上是

Substring(0,5);

,结果将是

"Servi"

我需要做什么才能获得发送参数的值?

提前感谢您的回复。

修改:粘贴原始

这是服务界面:

[ServiceContract]
public interface IWordBook
{
    [OperationContract]
    bool WCFFunction(string parameter1, string parameter2);
}

这是服务实现:

[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
public class WCFService : IWCFService
{
    public bool WCFFunction(string parameter1, string parameter2)
    {
        return BusinessRules.BusinessFunction(parameter1, parameter2);
    }
}

这就是我从ASP.NET WebForms应用程序中调用它的方式。

protected void Button_Click(object sender, EventArgs e)
{
    ServiceReference.WCFServiceClient service = new ServiceReference.WCFServiceClient();

    service.WCFFunction("string1", "string2");
}

1 个答案:

答案 0 :(得分:0)

这是原始代码吗?如果是,则表示您正在实现错误的界面。此外,还需要更多的东西。客户电话看起来没问题。