0

I have a WCF Service hosted on a Windows Service that runs on the same network using its own credentials. Security is not important. However, speed and reliability are important.

So, I tried with a netTcpBinding binding. However, I noticed that when I reference the Service into the client. It adds to the configuration file the identity tag with the information of the account that the service is running on:

<identity>
    <userPrincipalName value="account@domain" />
</identity>

I really don't want to have this in the client's configuration file, nor I want to pass it programmatically.

When I use instead a basicHttpBinding, I noticed that it does not add this tag. However, I still want to stick with net.tcp. So, my next try was to use a customBinding

So, here is where my problem is. I am not able to reference the custom binding to the client. Can someone verify my configuration? Also. Will this be enough to ignore completely the identity tag? If this is not the proper way, what would be the proper way? Thanks

<system.serviceModel>
    <services>
        <service name="LicenseServiceLogic.LicenseService">
            <endpoint address="net.tcp://localhost:8000/LicenseService"
                      binding="myCustomBinding"
                      contract="LicenseServiceLogic.ILicenseService">
            </endpoint>
        </service>
    </services>
    <bindings>
      <customBinding>
          <binding name="myCustomBinding">
              <compactMessageEncoding>
               <binaryMessageEncoding/>
              </compactMessageEncoding>
              <tcpTransport listenBacklog ="100" 
                            maxBufferPoolSize ="524288" 
                            maxBufferSize ="2147483647" 
                            maxReceivedMessageSize ="2147483647"/>
          </binding>
      </customBinding>
   </bindings>
   <client>
    <endpoint binding="customBinding" 
              bindingConfiguration="myCustomBinding"
              contract="IMetadataExchange"
              name="http" />
   </client>
</system.serviceModel>
Luis Lavieri
  • 4,064
  • 6
  • 39
  • 69

1 Answers1

1

First, the reason that we could not reference the custom binding to the client is we should add MEX service endpoint and enable the service metadata behavior. Like below,

    <system.serviceModel>
      <services>
        <service name="VM1.MyService" behaviorConfiguration="mybehavior">
          <endpoint address="" binding="netTcpBinding" contract="VM1.IService" bindingConfiguration="mybinding">
          </endpoint>
          <endpoint address="mex" binding="mexTcpBinding" contract="IMetadataExchange" ></endpoint>
          <host>
            <baseAddresses>
              <add baseAddress="net.tcp://localhost:5566"/>
            </baseAddresses>
          </host>
        </service>
      </services>
      <bindings>
        <netTcpBinding>
          <binding name="mybinding">
            <security mode="None"></security>
          </binding>
        </netTcpBinding>
      </bindings>
      <behaviors>
        <serviceBehaviors>
          <behavior name="mybehavior">
            <serviceMetadata />
          </behavior>
        </serviceBehaviors>
      </behaviors>
</system.serviceModel>

Besides, if we don’t want to add the identity tag to the client configuration, just we need to do is to set the Security Mode to NONE. As shown above.
For Mex endpoint details.
https://learn.microsoft.com/en-us/dotnet/framework/wcf/feature-details/metadata
Feel free to let me know if there is anything I can help with.

Abraham Qian
  • 7,117
  • 1
  • 8
  • 22
  • Thank you. This works without having to create a custom binding. There is something really weird in the behavior of the security. Here is the [post](https://stackoverflow.com/questions/2781683/wcf-client-endpoint-securitynegotiationexception-without-dns) that I found that talks about this. Since I did not have the `` tag, I was having problems with this. Really weird stuff! – Luis Lavieri Jul 12 '19 at 14:07
  • But with your example, I don't need to do anything related to the `Identity`. Thanks – Luis Lavieri Jul 12 '19 at 14:51