WebHttpBinding using webMessageEncoding: how to configure?

I have a WCF REST service. Its use of webHttpBinding and the configuration is as follows:

<service name="IndexingService.RestService" behaviorConfiguration="IndexingService.Service1Behavior">
    <endpoint
      address=""
      binding="webHttpBinding"
      bindingConfiguration="CustomMapper"
      contract="IndexingService.IIndexingService"
      behaviorConfiguration="webby"/>
</service>

CustomMapper is used to apply a custom WebContentTypeMapper, which I tried to configure as follows:

<binding name="CustomMapper">
        <webMessageEncoding webContentTypeMapperType="IndexingService.CustomContentTypeMapper, IndexingService" />
        <httpTransport manualAddressing="true" />
</binding>

But I can't figure out where in my web.config I have to insert these lines:

  • If I put these lines below, I get an error because webMessageEncoding is not a recognized element.
  • If I put lines under my own anchor tag, I get an error that wsHttpBinding does not have a specific CustomMapper !?

Can someone explain how to use custom mapper type with webHttpBinding?

+3
1

( , CustomMapper):

<binding name="CustomMapper">
   <webMessageEncoding webContentTypeMapperType=
             "IndexingService.CustomContentTypeMapper, IndexingService" />
   <httpTransport manualAddressing="true" />
</binding>

, webHttpBinding! Configuration!

:

<system.serviceModel>
  <bindings>
    <customBinding>
       <binding name="CustomMapper">
          <webMessageEncoding webContentTypeMapperType=
                 "IndexingService.CustomContentTypeMapper, IndexingService" />
          <httpTransport manualAddressing="true" />
       </binding>
    </customBinding>
  </bindings>
  <services>
    <service name="IndexingService.RestService"   
             behaviorConfiguration="IndexingService.Service1Behavior">
        <endpoint
           address=""
            binding="customBinding"
            bindingConfiguration="CustomMapper"
            contract="IndexingService.IIndexingService"
            behaviorConfiguration="webby"/>
     </service>
  </services>
</system.serviceModel>

+5

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


All Articles