Search code examples
wcfwsdl

Is it possible to return different wsdls for different contracts on the same service?


I have a WCF service implementing two contracts on two different endpoints. I would like a client to be able to point at an endpoint (rather than the base address of the service) and get the wsdl just for the contract implemented on that endpoint (rather than a wsdl containing all contracts).

Is this possible? If so, how can it be achieved?


Solution

  • Instead of setting up the service like shown below (with a single SVC file if hosting in IIS)

    <services>
        <service name="YourOrg.YourService">
    
            <endpoint address=""
                      binding="wsHttpBinding"
                      contract="YourOrg.IYourServiceThisContract" />
            <endpoint address="That"
                      binding="wsHttpBinding"
                      contract="YourOrg.IYourServiceThatContract" />
            <endpoint address="mex"
                      binding="mexHttpBinding"
                      contract="IMetadataExchange"/>
        </service>
    </services>
    

    Set each contract as a separate service class (with its own SVC file in the same IIS website)

    <services>
        <service name="YourOrg.ThisService">
    
            <endpoint address=""
                      binding="wsHttpBinding"
                      contract="YourOrg.IYourServiceThisContract" />
            <endpoint address="mex"
                      binding="mexHttpBinding"
                      contract="IMetadataExchange"/>
        </service>
    
        <service name="YourOrg.ThatService">
    
            <endpoint address=""
                      binding="wsHttpBinding"
                      contract="YourOrg.IYourServiceThatContract" />
            <endpoint address="mex"
                      binding="mexHttpBinding"
                      contract="IMetadataExchange"/>
        </service>
    </services>