【发布时间】:2011-08-19 09:30:33
【问题描述】:
我正在创建一个带有 REST 和 SOAP 端点的 WCF4 服务,以托管在 IIS 7.5 中。 我以 WCF4 REST 模板为例。 不过,到目前为止,我对我的设置有一些疑问。
这是我的网络配置
<system.serviceModel>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true"/>
<behaviors>
<endpointBehaviors>
<behavior name="REST">
<webHttp helpEnabled="true"/>
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior name="MEXGET">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service behaviorConfiguration="MEXGET" name="Project.WebService.VehicleService">
<endpoint
address=""
behaviorConfiguration="REST"
binding="webHttpBinding"
contract="Project.WebService.IVehicleService" />
<endpoint
address="soap"
binding="basicHttpBinding"
contract="Project.WebService.IVehicleService" />
<endpoint
address="mex"
binding="mexHttpBinding"
contract="IMetadataExchange" />
</service>
</services>
</system.serviceModel>
我删除了 standardEndpoints 部分并添加了我自己的端点。 没有 .svc 文件,因为我在 global.asax 中设置了路由,如下所示
private void RegisterRoutes()
{
RouteTable.Routes.Add(new ServiceRoute("VehicleService", new WebServiceHostFactory(), typeof(VehicleService)));
}
可以通过http://localhost:1313/ServiceTest/VehicleService/help访问帮助页面
我还使用 WCF 测试客户端访问 http://localhost:1313/ServiceTest/VehicleService/mex 显示 SOAP 端点的元数据
但是如何检索服务的 WSDL?
使用 svc 文件,我可以在 http://localhost:1313/ServiceTest/VehicleService.svc?wsdl 找到 wsdl,但是我没有 .svc 文件。 我也无法在 http://localhost:1313/ServiceTest/VehicleService?wsdl 或 http://localhost:1313/ServiceTest/VehicleService/soap?wsdl 找到 WSDL
如果我想为 SOAP 端点发布 WSDL,是否需要添加 .svc 文件?
【问题讨论】:
标签: wcf web-services rest soap wsdl