WCF parameter out bool

2

I created a WebService WCF , and in the interface IService1.cs I put the signature of the methods

[ServiceContract]
public interface IService1 {
     [OperationContract] bool insertConsulta(BConsulta bCos);
     [OperationContract] bool alterConsulta(BConsulta bCos);
}

From there I implemented this interface in the web service Service1.svc , and stayed like this

public class Service1 : IService1 {
     NConsulta nCos = new NConsulta();
     public bool insertConsulta(BConsulta bCos) {
        return nCos.insertConsulta(bCos);
     }
     public bool alterConsulta(BConsulta bCos) {
        return nCos.alterConsulta(bCos);
     }
}

Then I referred the Web Service to the project and put it as the name of that reference as localhost .

In Windows Form I installed the WebService

localhost.Service1 service = new localhost.Service1();

The following problem when I want to consume the web service it gives an error in web service methods that has bool return, in the interface I ask for 1 parameter and when I put service.insertConsulta(bCos); it I asked for 2 more parameters and it says the following:

void Service1.insertConsulta(BConsulta bCos, out bool insertConsultaResult, out bool insertConsultaResultSpecified)

The other methods that return void work normally, but those with boolean return appear this error, Dai I do not know what to do!

    
asked by anonymous 21.05.2016 / 18:33

1 answer

1

Instead of using the option to add the reference to a Web Service , try using the add reference to a "Service Reference" option. The first is the option for .ASMX (old) services, while the latter is the option that works best with WCF.

Note that what you have now should work - if you call the service as in the code below you will get the result of the call in the variable resultado .

bool resultado, naoUsado;
service.insertConsulta(bCos, out resultado, out naoUsado);
if (resultado) { ... }
    
21.05.2016 / 19:09