JSON オブジェクトを返す WCF サービスを作成しようとしています。私の最初の問題は、それを呼び出すために公開されているサービスメソッドが表示されないことです。「http://localhost:60090/VehicleDataService/detailbydivision?divisionId=1&year=2012」のようにサービス メソッドを呼び出すと、404 エラーが発生します。
Web.Config....
<system.serviceModel>
<services>
<service name="GMEOG.VehicleDataService" behaviorConfiguration="metadataBehavior">
<endpoint address="" binding="webHttpBinding" contract="GMEOG.IVehicleDataService" behaviorConfiguration="VehicleDataServiceBehavior">
<identity>
<dns value="" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="metadataBehavior">
<!-- 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="true"/>
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="VehicleDataServiceBehavior">
<webHttp helpEnabled="true" defaultOutgoingResponseFormat="Json" />
</behavior>
</endpointBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
これが私のインターフェースです....
[ServiceContract(Namespace = "GMEOG.VehicleDataService", Name = "VehicleDataService")]
public interface IVehicleDataService
{
[OperationContract]
[WebInvoke(Method = "GET",
ResponseFormat = WebMessageFormat.Json,
RequestFormat = WebMessageFormat.Json,
BodyStyle = WebMessageBodyStyle.WrappedResponse,
UriTemplate = "DetailByDivision?divisionId={divisionId}&year={year}")]
[return: MessageParameter(Name = "Vehicle")]
List<Vehicle> DetailByDivision(string divisionId, string year);
}