2011-06-20 11 views
0

SOAPとRESTを1つの屋根の下でいくつかの修正を加えて組み合わせようとしています。しかし、私はその可能性があるかどうかは分かりません。私のコードは以下の通りですが、RESTだけで動作していましたが、余分なWebサービスをSOAP(設定を使用して)として追加しようとして以来、動作しませんでした。私はインターフェイスを持っているその構成方法...このようにWCFサービスをREST&SOAPとして設定することはできますか?

わからない:

​​

とCS(分離コード):

[ServiceContract] 
public interface IVLSContentServiceREST 
{ 
    [OperationContract] 
    [WebGet] 
    string EchoWithGet(string s); 

    [OperationContract] 
    [WebInvoke] 
    string EchoWithPost(string s); 

} 

[ServiceContract] 
public interface IVLSContentServiceSOAP 
{ 
    [OperationContract] 
    [WebGet] 
    string EchoWithGet(string s); 

    [OperationContract] 
    [WebInvoke] 
    string EchoWithPost(string s); 
} 

をそれから私はこれでVLSContentService.svcと呼ばれるファイルを持っていますファイル:

public class VLSContentService : IVLSContentServiceSOAP, IVLSContentServiceREST 
{ 

    string IVLSContentServiceSOAP.EchoWithGet(string s) 
    { 
     return "You said " + s; 
    } 

    string IVLSContentServiceSOAP.EchoWithPost(string s) 
    { 
     return "You said " + s; 
    } 


    string IVLSContentServiceREST.EchoWithGet(string s) 
    { 
     return "You said " + s; 
    } 

    string IVLSContentServiceREST.EchoWithPost(string s) 
    { 
     return "You said " + s; 
    } 

} 

と設定:

<?xml version="1.0"?> 
<configuration> 

    <system.web> 
     <compilation debug="true" targetFramework="4.0" /> 
    </system.web> 

    <system.serviceModel> 

    <!---Add the service--> 
    <services> 
     <service behaviorConfiguration="VLSContentServiceBehaviour" name="VLSContentService"> 
     <endpoint address="rest" behaviorConfiguration="VLSContentServiceEndpointBehaviour" binding="webHttpBinding" contract="IVLSContentServiceREST"/> 
     <endpoint address="soap" behaviorConfiguration="VLSContentServiceEndpointBehaviour" binding="basicHttpBinding" contract="IVLSContentServiceSOAP"/> 
     </service> 
    </services> 

    <!---Add the behaviours--> 
    <behaviors> 
     <serviceBehaviors> 
     <behavior name="VLSContentServiceBehaviour"> 
      <serviceMetadata httpGetEnabled="true"/> 
      <serviceDebug includeExceptionDetailInFaults="true"/> 
     </behavior> 
     </serviceBehaviors> 


     <!---Add the behaviours--> 
     <endpointBehaviors> 
     <behavior name="VLSContentServiceEndpointBehaviour"> 
      <webHttp/> 
     </behavior> 
     </endpointBehaviors> 
    </behaviors> 

    </system.serviceModel> 
</configuration> 
+0

を使用して2つのエンドポイントで同じ契約をホストします。後で解決策を投稿します。 –

答えて

3

あなたは契約の2つのバージョンを必要としない - ちょうどはいそれが可能だと私はそのようにやっ異なるバインディング

<services> 
    <service behaviorConfiguration="VLSContentServiceBehaviour" name="VLSContentService"> 
    <endpoint address="rest" behaviorConfiguration="VLSContentServiceEndpointBehaviour" binding="webHttpBinding" contract="IVLSContentService"/> 
    <endpoint address="soap" behaviorConfiguration="VLSContentServiceEndpointBehaviour" binding="basicHttpBinding" contract="IVLSContentService"/> 
    </service> 
</services> 
関連する問題