Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WCF: operations with out parameters are not supported

Tags:

rest

.net

wcf

I've created a simple WCF service inside of WebApplication project.

[ServiceContract(Namespace = "http://my.domain.com/service")]
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
public class MyService
{
    [OperationContract]
    public string PublishProfile(out string enrollmentId, string registrationCode)
    {
        enrollmentId = null;
        return "Not supported";
    }

built - everything is compiled successfully

After that I've tried to open service in browser, I've got the following error:

Operation 'PublishProfile' in contract 'MyService' specifies an 'out' or 'ref' parameter. Operations with 'out' or 'ref' parameters are not supported

Can't I use 'out' parameters?

What is wrong here?

Thanks

P.S. I use VS2008 SP1, .NET 3.5

like image 687
Budda Avatar asked Jan 07 '11 21:01

Budda


2 Answers

The problem in my case was that default service configuration created in my ASP.NET application with Visual Studio wizard was a service type. Endpoint binding was "webHttpBinding". As far as I understand now it is binding for REST services, and they just don't have physical ability to work with out parameters. For them out parameter is not supported. And what I actually needed was a 'basicHttpBinding" that allows to work with out parameters.

Many thanks to everybody who helped me to figure out that.

like image 88
Budda Avatar answered Oct 02 '22 00:10

Budda


The answer I've found was:

"The idea of an out parameter is that the method will instantiate the null reference that you pass in. A web service is stateless; therefore the handle that you have on an object that goes into a webservice as a parameter will not be the same as the one that makes it into the webservice server side. The nature of this prevents out parameters."

Source

like image 23
Kees C. Bakker Avatar answered Oct 02 '22 02:10

Kees C. Bakker