2

Based on this answer I created following class that implements two WCF services:

public class WcfEntryPoint : IMyService1, IMyService2
{
    #region IMyService1
    #endregion

    #region IMyService2
    #endregion
}

It's hosted in Windows Service. App.config looks like:

<system.serviceModel>
<services>
  <service name="TestWcfProject.WcfEntryPoint" behaviorConfiguration="WcfEntryPointBehavior">
    <host>
      <baseAddresses>
        <add baseAddress="http://localhost:8000/TestWcfProject/service"/>
      </baseAddresses>
    </host>
    <!-- this endpoint is exposed at the base address provided by host: http://localhost:8000/TestWcfProject/service  -->
    <endpoint address="Service1" binding="wsHttpBinding" contract="TestWcfProject.IMyService1" />
    <endpoint address="Service2" binding="wsHttpBinding" contract="TestWcfProject.IMyService2" />
    <!-- the mex endpoint is exposed at http://localhost:8000/TestWcfProject/service/mex -->
    <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
  </service>
</services>
<behaviors>
  <serviceBehaviors>
    <behavior name="WcfEntryPointBehavior">
      <serviceMetadata httpGetEnabled="true"/>
      <serviceDebug includeExceptionDetailInFaults="False"/>
    </behavior>
  </serviceBehaviors>
</behaviors>
</system.serviceModel>

In order to use these services from some client application I generate proxy code by the command:

SvcUtil.exe http://localhost:8000/TestWcfProject/service?wsdl

The problem is that generated WcfEntryPoint.cs contains proxy code for both IMyService1 and IMyService2.

How can I generate proxy code only for IMyService1 or IMyService2 but not for both together? I've tried to launch

SvcUtil.exe /excludeType:TestWcfProject.IMyService2 http://localhost:8000/TestWcfProject/service?wsdl

with no luck.

I know that what I need could be achieved by implementing IMyService1 and IMyService2 in two different classes. But for the project it's essential that both services are implemented by the same class.

Community
  • 1
  • 1
CodeFuller
  • 30,317
  • 3
  • 63
  • 79

1 Answers1

1

How can I generate proxy code only for IMyService1 or IMyService2 but not for both together?

Its not something svcutil supports. However you can change how your service publishes its meta data.

On the service you can:

  1. Hide service operations from being exposed by the MEX endpoint.
  2. Add a second Custom Mex endpoint with a path of "Mex2".

Between these two references you should be able to create two custom mex endpoints for the service. Each endpoint publishes a subset of the methods for a particular use case.

Community
  • 1
  • 1
ErnieL
  • 5,773
  • 1
  • 23
  • 27