How to add Custom Service Behavior To WCF Configuration

Viewed 7928

I have a service with ComplexType in the Uri Template Parameter, I have Override the CanConvert() and ConvertStringToValue() methods to the class MyQueryStringConverter.

I need to add that behavior to the web.config file.

Here is the Behavior

public class MyWebHttpBehavior : WebHttpBehavior
    {
        protected override QueryStringConverter GetQueryStringConverter(OperationDescription operationDescription)
        {
            return new MyQueryStringConverter();
        }
    }

Here Is the Configuration File :

<system.serviceModel>
        <bindings>
            <webHttpBinding>
                <binding name="webHttp"
                 maxReceivedMessageSize="20000000" >
                    <security mode="None">
                        <transport clientCredentialType = "None"/>
                    </security>
                </binding>
            </webHttpBinding>

        </bindings>
        <behaviors>
            <serviceBehaviors>
                <behavior name="mexBehaviour">
                    <serviceMetadata httpGetEnabled="true"/>
                    <useRequestHeadersForMetadataAddress>
                        <defaultPorts>
                            <add scheme="http" port="80" />
                        </defaultPorts>
                    </useRequestHeadersForMetadataAddress>
                </behavior>
            </serviceBehaviors>
            <endpointBehaviors>
                <behavior name="web">
                    <webHttp/>
                </behavior>
            </endpointBehaviors>
        </behaviors>
        <services>
            <service name="Service.Service1" behaviorConfiguration="mexBehaviour">
                <endpoint address="" binding="webHttpBinding" contract="Service.IService1" bindingConfiguration="webHttp" behaviorConfiguration="web"/>
                <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange">

                </endpoint>

            </service>
        </services>
    </system.serviceModel>

Please help how to add that behavior.

1 Answers
Related