相关疑难解决方法(0)

使用Routes消除WCF 4服务的URL中的.svc?

我在IIS 7.5上使用WCF 4,并希望从我所有RESTful服务的URL中删除默认的.svc扩展名.我已经看到了使用Url Rewrite Module和IHttpModule记录的方法,但我不想采用这些方法.

我模糊地熟悉ASP.NET MVC中引入的Routes的概念,据我所知,它们现在已经从Net4中作为System.Web.Routing从MVC中抽象出来.但是在查看文档时,我需要将一个Global.asax文件添加到我的项目中,我并不是真的热衷于此.有没有其他方法来处理这个?

我也看过基于配置的激活功能,但这似乎只是消除了.svc文件,但仍然要求我在我的服务网址中使用.svc.

任何人都可以在这里总结我的选择,因为我的网址中不需要.svc吗?

rest wcf

12
推荐指数
2
解决办法
2万
查看次数

如何使用REST/SOAP端点发布WCF 4.0服务的WSDL

我正在创建一个WCF4服务,其REST和SOAP端点将在IIS 7.5中托管.我以WCF4 REST模板为例.但是到目前为止我对我的设置有几个问题.

这是我的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>
Run Code Online (Sandbox Code Playgroud)

我删除了standardEndpoints部分并添加了自己的端点.没有.svc文件,因为我在global.asax中设置了路由,如下所示

private void RegisterRoutes()
{
    RouteTable.Routes.Add(new ServiceRoute("VehicleService", new WebServiceHostFactory(), typeof(VehicleService)));
}
Run Code Online (Sandbox Code Playgroud)

可以通过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 …

rest wcf soap wsdl web-services

3
推荐指数
1
解决办法
1万
查看次数

IIS上的WCF服务.如何摆脱URL路径中的"Service.svc"组件?

我在IIS上托管了WCF服务.出于商业原因,我不能发布此实例的公共URL,但我相信你会得到我的意思:

问题是,为了到达我的端点,似乎我已经包含Service.svc了路径段的一部分,即,我必须使用这样的URL:

http://<domain>/<app-name>/Service.svc/<relative-path>

我怎么能避免这个?我的意思是,我想通过以下方式访问我的服务:

http://<domain>/<app-name>/<relative-path>

当我在开发过程中自我托管服务时,我完全能够做到这一点.


最后,但这不是那么超然,浏览到http://<domain>/<AppName>/Service.svcURL会显示标准服务信息页面:

有没有办法可以防止这种情况发生?

在此输入图像描述

.net c# iis wcf wcf-binding

1
推荐指数
1
解决办法
4114
查看次数

标签 统计

wcf ×3

rest ×2

.net ×1

c# ×1

iis ×1

soap ×1

wcf-binding ×1

web-services ×1

wsdl ×1