WCF Web API(REST)を使用してストリーミングデータをサポートする

StackOverflow https://stackoverflow.com/questions/5935656

  •  30-10-2019
  •  | 
  •  

質問

次の問題があります。私がこれまでに行った手順について説明させてください...

  1. Visual Studioで新しいWCFサービスアプリケーションを作成しました
  2. 次に、Nugetを介してプロジェクトを更新して、最新のWeb HTTP Libs(webapi.dll)を取得しました
  3. 次に、このように見えるサービス方法を作成しました

`

[ServiceContract]
public interface IService
{
        [OperationContract]
        [WebInvoke(Method="POST", UriTemplate="{value}")]
        string GetData(int value, Stream inputDocument);
}

`

今、私を見ようとしています .svc Browswerでは、エラーが発生します。操作中のリクエストGetDataがストリームになるには、操作にはタイプがストリームである単一のパラメーターが必要です"

これが構成の問題であることはわかっています、私は何が変更する必要があるかわからない web.config 気をつけて、これは新しいHTTPサポートの前のWCFで一般的な問題であったようです。これが新しいAPIで箱から出していないことに驚いています。

ポインターはありますか?

ありがとう

編集]設定を含めました...

<system.serviceModel>
    <services>
      <service name="MyService.Service" behaviorConfiguration="serviceBehaviour">
        <endpoint behaviorConfiguration="endPointBehaviour" address="" binding="webHttpBinding" contract="MyService.IService"/>
      </service>
    </services>    
    <bindings>
      <webHttpBinding>
        <binding transferMode="Streamed" name="webHttpBinding" />
      </webHttpBinding>
    </bindings>

    <behaviors>
      <endpointBehaviors>
        <behavior name="endPointBehaviour">
          <webHttp/>
        </behavior>
      </endpointBehaviors>

      <serviceBehaviors>
        <behavior name="serviceBehaviour">
          <serviceMetadata httpGetEnabled="true"/>
          <serviceDebug includeExceptionDetailInFaults="true" />
        </behavior>
      </serviceBehaviors>
    </behaviors>    
  </system.serviceModel>

正しい解決策はありません

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top