WCF Native Binding - Content Type Not Supported by Service

I defined a user binding in the my.config file of my client and server, but when I try to connect, I get this error, the server is running IIS 7

Content Type Application / xml; charset = utf-8 is not supported by http: //localhost/contentservice.svc/PairService . Customer and service relationships may not be compatible.

Server:

  <system.serviceModel>
  <client>
    <endpoint binding="customBinding"  bindingConfiguration="BinaryBinding" contract="Me.IContentService" name="ContentStagingEndpoint" />
  </client>
  <bindings>
    <customBinding>
      <binding name="BinaryBinding">
        <binaryMessageEncoding/>
        <httpTransport/>
      </binding>
    </customBinding>
  </bindings>
  </system.serviceModel>

Customer:

<system.serviceModel>
  <behaviors>
    <serviceBehaviors>
      <behavior name="ContentService">
        <serviceMetadata httpGetEnabled="true"/>
        <serviceDebug includeExceptionDetailInFaults="true"/>
      </behavior>
    </serviceBehaviors>
  </behaviors>
  <services>
    <service behaviorConfiguration="ContentService" name="Me.ContentService">
      <endpoint address="" binding="customBinding"  bindingConfiguration="BinaryBinding" contract="Contracts.IContentService">
        <identity>
          <dns value="localhost"/>
        </identity>
      </endpoint>
      <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
    </service>
  </services>
  <bindings>
    <customBinding>
      <binding name="BinaryBinding">
        <binaryMessageEncoding/>
        <httpTransport/>
      </binding>
    </customBinding>
  </bindings>
</system.serviceModel>

and here is the code that initiates the call:

var chan = New WebChannelFactory(Of IContentService)(New Uri("http://localhost/contentservice.svc")).CreateChannel();

chan.PairService();
+3
source share
1 answer

Found solution, I had to use ChannelFactoryinsteadWebChannelFactory

var proxy =  ChannelFactory(Of IContentService).CreateChannel(New EndpointAddress("http://localhost/service.svc"))
0
source

Source: https://habr.com/ru/post/1753622/


All Articles