WCF:如何几种服务结合成单一的WSDL [英] WCF: How to combine several services into single WSDL

查看:194
本文介绍了WCF:如何几种服务结合成单一的WSDL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的ASP.NET WebForms的项目,我不得不在WCF服务库项目,该项目包含不同的WCF服务,为每个业务对象的引用。该服务在IIS托管,并有可能通过路径我在Global.asax定义得到WSDL:一是通过为每个服务一条路线WSDL

In my ASP.NET WebForms project I have a reference to the WCF services library project, which contains different WCF services for each business object. The services are hosted in IIS and it's possible to get WSDL via routes I defined in the Global.asax: one WSDL via one route for each service.

我真正需要的 - 选择什么我想为不同的客户服务,并为设置所选服务的单一WSDL一定的能力。
我真的AP preciate任何形式的帮助!在此先感谢

What I really need - some ability to choose services what I want to provide for different customers and generate a SINGLE WSDL for the chosen services set. I'd really appreciate any kind of help! Thanks in advance

推荐答案

是它可以配置WCF路由服务,并得到WSDL文件,形成背后的个性化服务。

Yes its possible to configure WCF routing service and get WSDL files form individual service behind it.

第1步 - 设置 HttpGetEnabled设置为true 和配置MEX端点的所有WCF服务这些都是你的路由器后面服务

Step 1 - Set HttpGetEnabled set to true and configure MEX Endpoint in all WCF Service those are behind your router service

 <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 should specify the "MEX" endpoint address

 <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>

您完成所有的工作。
您可以直接访问您的服务通过下面的WSDL文件的URL分别:

You are all done. You can directly access the WSDL file of your services by below URLS individually :

http://localhost/WcfRoutingService/RoutingService.svc/StandardService
http://localhost/WcfRoutingService/RoutingService.svc/PremiumService

这篇关于WCF:如何几种服务结合成单一的WSDL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆