最近、WCF SOAP サービスを REST/JSON サービスに変換しました。こちらの回答で詳しく説明されているように、Visual Studio のサービス参照の追加機能では、JSON サービスのコードを生成できません。その質問の回答のリンクされた記事は、問題を解決するために WCF を REST と SOAP の両方として公開する可能性をほのめかしていますが、その方法については詳しく説明していません。
これが可能かどうか、また可能であれば設定方法を知っている人はいますか?
WCF REST サービスの WSDL を読み取り、C# クラスを生成するコード ジェネレーターを自分で作成するという選択肢は常にありますが、これよりも簡単な解決策があるはずです。
参考までに、私のweb.config:
<system.serviceModel>
<behaviors>
<endpointBehaviors>
<behavior name="RestBehavior">
<webHttp />
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior name="GetBehavior" >
<serviceMetadata httpGetEnabled="true" />
<serviceDebug
httpHelpPageEnabled="true"
includeExceptionDetailInFaults="true"
/>
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<webHttpBinding>
<binding name="WebHttpBinding">
<security mode="TransportCredentialOnly">
<transport clientCredentialType="None" />
</security>
</binding>
</webHttpBinding>
</bindings>
<services>
<service name="Service" behaviorConfiguration="GetBehavior">
<endpoint address=""
binding="webHttpBinding"
behaviorConfiguration="RestBehavior"
contract="IService"
bindingConfiguration="WebHttpBinding">
</endpoint>
</service>
</services>
</system.serviceModel>
私のサービスメソッドはすべて次の属性を持っています:
[WebInvoke(RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Wrapped)]