tags:

views:

37

answers:

1

I am trying to create a WCF Streaming Service. I have two requirements that I seem to be stumbling over trying to get this to work:

  • Length of stream size
  • Input parameters

My message contract looks like this:

[MessageContract]
public class MyStream
{
 [MessageHeader]
 public long StreamSize;

 [MessageBodyMember]
 public Stream StreamData;
}  

My operation contract looks like this:

[ServiceContract]
public interface IStreamService
{
     [OperationContract]
     MyStream GetData(string data);
}

The error message I receive when trying to use the web service is this:

The operation 'GetData' could not be loaded because it has a parameter or return type of type System.ServiceModel.Channels.Message or a type that has MessageContractAttribute and other parameters of different types. When using System.ServiceModel.Channels.Message or types with MessageContractAttribute, the method must not use any other types of parameters.

From my understanding of this post, I need to use a message contract to get the length of my stream, but when I switch from a data contract to a message contract I am no longer allowed to pass in input parameters.

Is there a configuration change I'm missing? Or something else I can try? Thanks!

+1  A: 

Hello,

you also have to create MessageContract for request.

[MessageContract]
public class GetDataRequest
{
  [MessageBodyMember(Name="data")]
  public string Data { get; set; }
}

Then you define your operation as follows:

[OperationContract]
MyStream GetData(GetDataRequest request);

Best regards, Ladislav

Ladislav Mrnka
Wow - how simple! Thanks so much.
Blake Blackwell
The point is that if you use a message contact for response you also have to use it for request and vice-versa.
Ladislav Mrnka