Maksim Ramanovich
Maksim Ramanovich

Reputation: 621

WCF: How to combine several services into single 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.

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.

Upvotes: 3

Views: 2531

Answers (2)

elbaz
elbaz

Reputation: 1

the problem in your solution is : you give to your clients a WSDL with the address of your web service PremiumWCFService and StandardService , and the clients (WCF) can use that directly without check and can call your web sevices without call routing service.

Upvotes: 0

Mike
Mike

Reputation: 106

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

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>

Step 2- Configure Routing Service

Add Endpoint

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

Add service behaviour

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

      </serviceBehaviors>
    </behaviors>

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>

Specify the 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 by below URLS individually :

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

Upvotes: 7

Related Questions