別の ASP.net プロジェクトから使用したい RESTful WCF サービスを開発しています。
REST を使用してサービスを利用するために ASP プロジェクト内からサービス参照を使用することは可能ですか、それともすべてのサービス参照は SOAP として扱われますか?
サービス ライブラリをサービス参照として使用したり、HttpClient を使用して WCF スターター ツールキットを使用して REST サービスを使用したりする例はたくさんありますが、私が望んでいたことを実行するものは見つかりませんでした。
以下は、サービス参照が追加されたときに自動生成される ASP.Net web.config ファイルからの抜粋です。ご覧のとおり、SOAP について言及しています。
<system.serviceModel>
<bindings>
<customBinding>
<binding name="WebHttpBinding_IDataCaptureService">
<textMessageEncoding maxReadPoolSize="64" maxWritePoolSize="16"
messageVersion="Soap12" writeEncoding="utf-8">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
</textMessageEncoding>
</binding>
</customBinding>
</bindings>
<client>
<endpoint binding="customBinding" bindingConfiguration="WebHttpBinding_IDataCaptureService"
contract="testRef.IDataCaptureService" name="WebHttpBinding_IDataCaptureService" />
</client>
</system.serviceModel>
これは、サービス web.config からの抜粋です。
<system.serviceModel>
<services>
<service behaviorConfiguration="DataCaptureService.Service1Behavior" name="eCRB.Service.DataCapture">
<endpoint address="" behaviorConfiguration="webBehaviour" binding="webHttpBinding" bindingConfiguration="" contract="eCRB.Service.IDataCaptureService">
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
</service>
</services>
<behaviors>
<endpointBehaviors>
<behavior name="webBehaviour">
<webHttp/>
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior name="DataCaptureService.Service1Behavior">
<!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
<serviceMetadata httpGetEnabled="true"/>
<!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<webHttpBinding>
<binding name="webBinding">
<security mode="None">
<transport clientCredentialType="None"/>
</security>
</binding>
</webHttpBinding>
</bindings>
</system.serviceModel>