WCF streaming service that returns the length of the stream and includes input parameters

I am trying to create a WCF streaming service. I have two requirements that I seem to stumble in trying to get this to work:

  • Stream size length
  • Input parameters

The contract for my message is as follows:

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

 [MessageBodyMember]
 public Stream StreamData;
}  

My job contract is as follows:

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

The error message that I get when I try to use the web service is as follows:

The GetData operation cannot be because it has a parameter or return type 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 should not use other types of Parameters.

, , , .

, ? - ? !

+3
1

MessageContract .

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

:

[OperationContract]
MyStream GetData(GetDataRequest request);
+2

Source: https://habr.com/ru/post/1759323/


All Articles