0

I have a WCf rest service which has two input parameters : string and Stream:

[OperationContract]      
[WebInvoke(Method = "POST", UriTemplate = "ImportStream/{Separator}", ResponseFormat = 
WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Bare)]
void ImportStream(string Separator, stream data);

My code:

public void ImportStream (string Separator, Stream inputpar)
{ //...
}

My objectif is to call the service with POSTMAN: https://localhost:44355/ServiceLias.svc/rest/ImportStream/Comma

and in the body , I write the Stream as Text ,

but I have error from the beginning :

For request in operation ImportStream to be a stream the operation must have a single parameter whose type is Stream.

How can I fix it ? Or there is any idea to achieve my objectif ? Thanks,

Backs
  • 24,430
  • 5
  • 58
  • 85
IngTun2018
  • 329
  • 1
  • 10
  • Does this answer your question? [WCF Rest Webservice with stream](https://stackoverflow.com/questions/6366489/wcf-rest-webservice-with-stream) – Selim Yildiz Jan 15 '20 at 16:42

1 Answers1

2

The definition of the function signature doesn’t comply with the rules to enable stream data in WCF. It violates the below definition.

The parameter that holds the data to be streamed must be the only parameter in the method. For example, if the input message is the one to be streamed, the operation must have exactly one input parameter. Similarly, if the output message is to be streamed, the operation must have either exactly one output parameter or a return value.

Please refer to the official document of how to enable Streaming.
https://learn.microsoft.com/en-us/dotnet/framework/wcf/feature-details/how-to-enable-streaming
Feel free to let me know if there is anything I can help with.

Abraham Qian
  • 7,117
  • 1
  • 8
  • 22