Note that there are some explanatory texts on larger screens.

plurals
  1. POWCF consumed as WebService adds a boolean parameter?
    text
    copied!<p>I've created the default WCF Service in VS2008. It's called "Service1"</p> <pre><code>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; } } </code></pre> <p>It works fine, the interface is IService1:</p> <pre><code>[ServiceContract] public interface IService1 { [OperationContract] string GetData( int value ); [OperationContract] CompositeType GetDataUsingDataContract( CompositeType composite ); // TODO: Add your service operations here } </code></pre> <p>This is all by default; Visual Studio 2008 created all this.</p> <p>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. </p> <p>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. </p> <p>When I tried to consume this, I found out that the GetData(int) method, was now GetData(int, bool).</p> <p>Here's the code</p> <pre><code> private void button1_Click( object sender, EventArgs e ) { localhost.Service1 s1 = new WindowsFormsApplication2.localhost.Service1(); Console.WriteLine(s1.GetData(100, false)); } </code></pre> <p>Notice the false in the GetData call?</p> <p>I don't know what that parameter is or where did that come from, it is called "bool valueSpecified".</p> <p>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).</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload