2012-11-28 18 views
5

私はC#と.NET Framework 4.0でWCFサービスを開発しています。私はこれを行うにはwebHttpBindingを使用していbasicHttpBinding&webHttpBinding一緒に

[OperationContract] 
[WebInvoke(Method = "POST", 
    ResponseFormat = WebMessageFormat.Json, 
    BodyStyle = WebMessageBodyStyle.Bare, 
    UriTemplate = "filteredOrders/")] 
OrderContract[] GetOrders(IdsMessage msg); 

[OperationContract] 
[WebInvoke(Method = "POST", 
    ResponseFormat = WebMessageFormat.Json, 
    BodyStyle = WebMessageBodyStyle.Bare, 
    UriTemplate = "completeFilteredOrders/")] 
OrderContract[] LoadCompleteFilteredOrders(IdsMessage msg); 

は、しかし、今、私はstreammingを使用して、そのWebサービスに画像を送信する必要があると私はそれを行うにはbasicHttpBindingを追加する必要があります。

basicHttpBindingを使用するこのWCF Webサービスに対して、新しい[OperationContract]をどうすればいいですか?

申し訳ありませんが、私はWCF開発で非常に新しいです。ところで

が、これは私ののWeb.configです:

<configuration> 
    <system.web> 
    <compilation debug="true" targetFramework="4.0" /> 
    </system.web> 
    <system.serviceModel> 
    <services> 
     <service name="EReportService.RestServiceImpl" behaviorConfiguration="ServiceBehaviour"> 
     <endpoint address="" binding="webHttpBinding" contract="EReportService.IRestServiceImpl" behaviorConfiguration="web"> 
     </endpoint> 
     </service> 
    </services> 
    <bindings> 
     <webHttpBinding> 
     <binding maxReceivedMessageSize="2097152" maxBufferSize="2097152" transferMode="Streamed"/> 
     </webHttpBinding> 
    </bindings> 
    <behaviors> 
     <serviceBehaviors> 
     <behavior name="ServiceBehaviour"> 
      <serviceMetadata httpGetEnabled="true"/>  
      <serviceDebug includeExceptionDetailInFaults="true"/> 
     </behavior> 
     </serviceBehaviors> 
     <endpointBehaviors> 
     <behavior name="web"> 
      <webHttp/> 
     </behavior> 
     </endpointBehaviors> 
    </behaviors> 
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" /> 
    </system.serviceModel> 
<system.webServer> 
    <modules runAllManagedModulesForAllRequests="true"/> 
    </system.webServer> 
    <connectionStrings> 

    </connectionStrings> 
</configuration> 
+1

可能な解決策:http://debugmode.net/2011/12/22/how-to-enable-rest-and-soap-both-on-the-same-wcf-service/ – VansFannel

答えて

8

ジャスト(2つのエンドポイントが同じアドレスを共有することはできません)別のアドレスを使用して別のエンドポイントを作成 - 既存のOperationContractを変更することができます非RESTfulメソッドを作成します。

<system.serviceModel> 
    <services> 
     <service name="EReportService.RestServiceImpl" behaviorConfiguration="ServiceBehaviour"> 
     <endpoint address="" binding="webHttpBinding" contract="EReportService.IRestServiceImpl" behaviorConfiguration="web"> 
     </endpoint> 
     <endpoint address="soap" binding="basicHttpBinding" contract="EReportService.IRestServiceImpl" > 
     </endpoint> 
     </service> 
    </services> 
</system.serviceModel>