How to expose MEX when I need the service to have NTLM authentication

Posted by Ram Amos on Stack Overflow See other posts from Stack Overflow or by Ram Amos
Published on 2012-10-21T08:46:50Z Indexed on 2012/10/21 17:01 UTC
Read the original article Hit count: 306

Filed under:
|

I'm developing a WCF service that is RESTful and SOAP, now both of them needs to be with NTLM authentication.

I also want to expose a MEX endpoint so that others can easily reference the service and work with it.

Now when I set IIS to require windows authentication I can use the REST service and make calls to the service succesfully, but when I want to reference the service with SVCUTIL it throws an error that it requires to be anonymous.

Here's my web.config:

<system.serviceModel>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true"/>
<bindings>
  <basicHttpBinding>
    <binding name="basicHttpBinding" maxReceivedMessageSize="214748563" maxBufferSize="214748563" maxBufferPoolSize="214748563">
      <security mode="TransportCredentialOnly">
        <transport clientCredentialType="Ntlm">

        </transport>
      </security>
    </binding>
  </basicHttpBinding>
  <webHttpBinding>
    <binding name="webHttpBinding" maxReceivedMessageSize="214748563" maxBufferSize="214748563" maxBufferPoolSize="214748563">
      <security mode="TransportCredentialOnly">
        <transport clientCredentialType="Ntlm">

        </transport>
      </security>
    </binding>
  </webHttpBinding>
  <mexHttpBinding>
    <binding name="mexHttpBinding"></binding>
  </mexHttpBinding>
</bindings>
<standardEndpoints>
  <webHttpEndpoint>
    <standardEndpoint name="" automaticFormatSelectionEnabled="true" helpEnabled="True">
    </standardEndpoint>
  </webHttpEndpoint>
</standardEndpoints>
<services>
  <service name="Intel.ResourceScheduler.Service" behaviorConfiguration="Meta">
    <clear />
    <endpoint address="soap" name="SOAP" binding="basicHttpBinding" contract="Intel.ResourceScheduler.Service.IResourceSchedulerService" listenUriMode="Explicit" />
    <endpoint address="" name="rest" binding="webHttpBinding" behaviorConfiguration="REST" contract="Intel.ResourceScheduler.Service.IResourceSchedulerService" />
    <endpoint address="mex" name="mex" binding="mexHttpBinding" behaviorConfiguration="" contract="IMetadataExchange" />
  </service>
</services>
<behaviors>
  <endpointBehaviors>
    <behavior name="REST">
      <webHttp />
    </behavior>
    <behavior name="WCFBehavior">
      <dataContractSerializer maxItemsInObjectGraph="2147483647" />
    </behavior>

  </endpointBehaviors>
  <serviceBehaviors>
    <behavior name="Meta">
      <serviceMetadata httpGetEnabled="true"/>
    </behavior>
    <behavior name="REST">
      <dataContractSerializer maxItemsInObjectGraph="2147483647" />
    </behavior>
    <behavior name="WCFBehavior">
      <serviceMetadata httpGetEnabled="true"/>
      <dataContractSerializer maxItemsInObjectGraph="2147483647" />
    </behavior>
    <behavior name="">
      <!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
      <serviceMetadata httpGetEnabled="true" />
      <!-- To receive exception details in faults for debugging purposes, set the value below to true.  Set to false before deployment to avoid disclosing exception information -->
      <serviceDebug includeExceptionDetailInFaults="false" />
    </behavior>
  </serviceBehaviors>
</behaviors>

Any help will be appreciated.

© Stack Overflow or respective owner

Related posts about c#

Related posts about wcf