WCF: how to combine several services into one WSDL

In my ASP.NET WebForms project, I have a link to a WCF service library project that contains different WCF services for each business object. Services are hosted in IIS, and you can get WSDL through the routes defined in Global.asax: one WSDL through one route for each service.

What I really need is some ability to select the services that I want to provide for different clients, and create SINGLE WSDL for the selected set of services.

+2
source share
2 answers

Yes, it is possible to configure the WCF routing service and get the WSDL files for a separate service.

Step 1 - Set the HttpGetEnabled set to true and configure the MEX endpoint in all WCF services that are behind the router

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

Step 2 - Configure Routing Service

Add end point

 <endpoint address="" binding="mexHttpBinding" name="mexEndpoint" contract="System.ServiceModel.Routing.IRequestReplyRouter"/> 

Add Service Behavior

  <behaviors> <serviceBehaviors> <behavior> <routing routeOnHeadersOnly="false" filterTableName="routingTable" /> <serviceDebug includeExceptionDetailInFaults="true" /> <serviceMetadata httpGetEnabled="false" /> </behavior> </serviceBehaviors> </behaviors> 

The client endpoint address must indicate 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> 

Specify a routing table

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

You are all done. You can directly access the WSDL file of your services using the individual URLs:

 http://localhost/WcfRoutingService/RoutingService.svc/StandardService http://localhost/WcfRoutingService/RoutingService.svc/PremiumService 
+7
source

the problem in your solution is this: you provide your clients with WSDL with the address of your web service PremiumWCFService and StandardService, and clients (WCF) can directly use it without checking and can call your web services without call routing service.

0
source

All Articles