WCF消耗的web服务增加了一个布尔参数?布尔、消耗、增加了、参数

由网友(君子坦荡荡)分享简介:我创建了一个VS2008的默认WCF服务。这就是所谓的服务1I've created the default WCF Service in VS2008. It's called "Service1"public class Service1 : IService1{public string GetData(...

我创建了一个VS2008的默认WCF服务。这就是所谓的服务1

I've created the default WCF Service in VS2008. It's called "Service1"

public class Service1 : IService1
{
    public string GetData( int value )
    {
        return string.Format("You entered: {0}", value);
    }

    public CompositeType GetDataUsingDataContract( CompositeType composite )
    {
        if ( composite.BoolValue )
        {
            composite.StringValue += "Suffix";
        }
        return composite;
    }
}

它工作正常,界面IService1:

It works fine, the interface is IService1:

[ServiceContract]
public interface IService1
{

    [OperationContract]
    string GetData( int value );

    [OperationContract]
    CompositeType GetDataUsingDataContract( CompositeType composite );

    // TODO: Add your service operations here
}

这是所有默认; Visual Studio 2008中创建了这一切。

This is all by default; Visual Studio 2008 created all this.

然后,我创建了一个简单的WinForms应用程序,以测试这一点。我添加了服务引用到我上面提到的服务,它的所有作品。我可以实例化和调用myservice1.GetData(100);我得到的结果。

I then created a simple Winforms app to "test" this. I added the Service Reference to my the above mentioned service and it all works. I can instanciate and call myservice1.GetData(100); and I get the result.

但我被告知,这项服务必须由通过Web服务一个WinForms .NET 2.0的应用程序被消耗掉,所以我接着引用添加到一个新的WinForms从头开始创建.NET 2.0的应用程序(只有一个的winform名为Form1中)。这一次,增加了web引用的时候,就添加了典型的本地主机一个属于Web服务;向导看到了WCF服务(在后台运行),并把它添加。

But I was told that this service will have to be consumed by a Winforms .NET 2.0 app via Web Services, so I proceeded to add the reference to a new Winforms .NET 2.0 application created from scratch (only one winform called form1). This time, when adding the "web reference", it added the typical "localhost" one belonging to webservices; the wizard saw the WCF Service (running on background) and added it.

当我试图消耗掉这一点,我发现原来的GetData(int)方法,现在的GetData(整型,布尔)。

When I tried to consume this, I found out that the GetData(int) method, was now GetData(int, bool).

这里的code

    private void button1_Click( object sender, EventArgs e )
    {
        localhost.Service1 s1 = new WindowsFormsApplication2.localhost.Service1();
        Console.WriteLine(s1.GetData(100, false));
    }

注意假中的GetData调用?

Notice the false in the GetData call?

我不知道这个参数是什么,或者哪里是从何而来,它被称为布尔valueSpecified。

I don't know what that parameter is or where did that come from, it is called "bool valueSpecified".

有谁知道这是哪里来的?别的我应该做的消耗WCF服务从.NET 2.0一个WebService? (的WinForms)。

Does anybody know where this is coming from? Anything else I should do to consume a WCF Service as a WebService from .NET 2.0? (winforms).

推荐答案

好吧好吧......显然here's答案和可能的解决方案或解决方案。

Well well… apparently here's the answer and possible solutions or workarounds.

阅读全文

相关推荐

最新文章