在我的ASP.NET WebForms项目中,我引用了WCF服务库项目,该项目包含每个业务对象的不同WCF服务.这些服务托管在IIS中,可以通过我在Global.asax中定义的路由获取WSDL:一个WSDL通过一条路由为每个服务.
解决方法
是的,可以配置WCF路由服务并获取WSDL文件,从而形成单独的服务.
步骤1 – 将HttpGetEnabled设置为true并在路由器服务后面的所有WCF服务中配置MEX端点
<service behaviorConfiguration="routingBehv" name="System.ServiceModel.Routing.RoutingService"> <host> <baseAddresses> <add baseAddress="http://localhost/WcfRoutingService/RoutingService.svc"/> </baseAddresses> </host> <endpoint address="http://localhost/WcfRoutingService/RoutingService.svc" binding="mexHttpBinding" name="mexEndpoint" contract="System.ServiceModel.Routing.IRequestReplyRouter"/> </service>
步骤2-配置路由服务
添加端点
<endpoint address="" binding="mexHttpBinding" name="mexEndpoint" contract="System.ServiceModel.Routing.IRequestReplyRouter"/>
添加服务行为
<behaviors> <serviceBehaviors> <behavior> <routing routeOnHeadersOnly="false" filterTableName="routingTable" /> <serviceDebug includeExceptionDetailInFaults="true" /> <serviceMetadata httpGetEnabled="false" /> </behavior> </serviceBehaviors> </behaviors>
客户端端点地址应指定“MEX”端点地址
<client> <endpoint address="http://localhost/PremiumWcfService/PremiumWCFService.svc/mex" binding="mexHttpBinding" contract="*" name="PremiumServiceMex"/> <endpoint address="http://localhost/StandardWCFService/StandardWCFService.svc/mex" binding="mexHttpBinding" contract="*" name="StandardServiceMex"/> </client>
指定路由表
<routing> <filters> <filter name="StandardServiceMexFilter" filterType="EndpointAddress" filterData="http://tempuri.org/WcfRoutingService/RoutingService.svc/StandardService" /> <filter name="PremiumServiceMexFilter" filterType="EndpointAddress" filterData="http://tempuri.org/WcfRoutingService/RoutingService.svc/sPreminuService" /> </filters> <filterTables> <filterTable name="routingTable"> <add filterName="StandardServiceMexFilter" endpointName="StandardServiceMex"/> <add filterName="PremiumServiceMexFilter" endpointName="PremiumServiceMex"/> </filterTable> </filterTables> </routing>
你们都完成了.
您可以通过以下URL单独直接访问服务的WSDL文件:
http://localhost/WcfRoutingService/RoutingService.svc/StandardService http://localhost/WcfRoutingService/RoutingService.svc/PremiumService
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。