2011-08-19 59 views
3

我正在使用REST和SOAP端点创建WCF4服务,并将其托管在IIS 7.5中。 我已经使用WCF4 REST模板作为示例。 但是我有几个关于我的设置的问题。如何使用REST/SOAP端点发布WSDL以用于WCF 4.0服务

这里是我的webconfig

<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部分并添加自己的端点。因为我已经设置在Global.asax路线 没有.SVC文件如下图所示

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?wsdlhttp://localhost:1313/ServiceTest/VehicleService/soap?wsdl

的WSDL我是否需要添加一个.svc文件,如果我要发布WSDL的SOAP终点?

回答

0

您应该能够直接使用MEX URL从浏览器获得WSDL:

http://localhost:1313/ServiceTest/VehicleService/mex 

的WcfTestClient几乎可以肯定这样做检索WSDL,因此它可以生成代理服务。