簡體   English   中英

如何在 WCF Rest Service 中傳遞多個參數:C# 中的字符串和流

[英]How to pass multiple parameters in WCF Rest Service: string and Stream in C#

我有一個 WCf 休息服務,它有兩個輸入參數:字符串和流:

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

我的代碼:

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

我的目標是使用 POSTMAN 調用服務:https://localhost:44355/ServiceLias.svc/rest/ImportStream/Comma

在正文中,我將 Stream 寫為 Text ,

但我從一開始就有錯誤:

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

我該如何解決? 或者有什么想法可以實現我的目標嗎? 謝謝,

函數簽名的定義不符合在 WCF 中啟用流數據的規則。 它違反了以下定義。

保存要流式傳輸的數據的參數必須是方法中的唯一參數。 例如,如果輸入消息是要流式傳輸的消息,則操作必須正好有一個輸入參數。 類似地,如果要流式傳輸輸出消息,則操作必須恰好有一個輸出參數或返回值。

開啟Streaming的方法請參考官方文檔。
https://docs.microsoft.com/en-us/dotnet/framework/wcf/feature-details/how-to-enable-streaming
如果有什么我可以幫忙的,請隨時告訴我。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM