c# – WebService消耗的WCF会添加一个布尔参数?
我在VS2008中创建了默认的WCF服务.被称为“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: [ServiceContract] public interface IService1 { [OperationContract] string GetData( int value ); [OperationContract] CompositeType GetDataUsingDataContract( CompositeType composite ); // TODO: Add your service operations here } 这是默认的; Visual Studio 2008创建了所有这一切. 然后我创建了一个简单的Winforms应用程序来“测试”这个.我添加了服务参考我上面提到的服务,它一切正常.我可以instanciate并调用myservice1.GetData(100);我得到结果. 但是我被告知,这个服务将不得不通过Web服务使用Winforms .NET 2.0应用程序,所以我继续添加了从头开始创建的一个新的Winforms .NET 2.0应用程序的引用(只有一个名为form1的winform).这次添加“web参考”时,它添加了属于webservices的典型的“localhost”;向导看到了WCF服务(在后台运行)并添加了它. 当我试图消耗这个,我发现GetData(int)方法现在是GetData(int,bool). 这是代码 private void button1_Click( object sender,EventArgs e ) { localhost.Service1 s1 = new WindowsFormsApplication2.localhost.Service1(); Console.WriteLine(s1.GetData(100,false)); } 注意GetData调用中的false? 我不知道这个参数是什么,或者哪个来自哪里,它被称为“bool valueSpecified”. 有谁知道这是从哪里来的?我还应该做些什么来从.NET 2.0中使用WCF服务作为WebService? (的WinForms). 解决方法
好吧,显然是
here’s的答案和可能的解决方法或解决方法.
(编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |