Monday, April 29, 2013

Difference between regular WCF and Ajax Enabled WCF service




ASP.NET AJAX ENABLED WCF SERVICE
REGULAR ASP.NET WCF SERVICE
<system.serviceModel>
        <behaviors>
            <endpointBehaviors>
                <behavior name="ServiceAspNetAjaxBehavior">
                    <enableWebScript />
                </behavior>
            </endpointBehaviors>
        </behaviors>
        <serviceHostingEnvironment aspNetCompatibilityEnabled="true" />
        <services>
            <service name="Service">
                <endpoint address=""behaviorConfiguration="ServiceAspNetAjaxBehavior"
                    binding="webHttpBinding"contract="Service" />
            </service>
        </services>
    </system.serviceModel>
<system.serviceModel>
        <behaviors>
            <serviceBehaviors>
                <behavior name="ServiceBehavior">
                    <serviceMetadata httpGetEnabled="true" />
                    <serviceDebug includeExceptionDetailInFaults="false" />
                </behavior>
            </serviceBehaviors>
        </behaviors>
        <services>
            <servicebehaviorConfiguration="ServiceBehavior"name="Service">
                <endpoint address="" binding="wsHttpBinding" contract="IService">
                    <identity>
                        <dns value="localhost" />
                    </identity>
                </endpoint>
                <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
            </service>
        </services>
    </system.serviceModel>
1.       Ajax Enabled service does not contain mex endpoint by default.
2.       Ajax Enabled service contains an endpoint behavior, which enable webscript access ( <enableWebScript>) .
Regular service does not contain any such default endpoint behavior, instead it contains a <serviceBehavior> which states httpGetEnabled=true
3.       Binding : Ajax enabled service uses “webHttpBinding” where as regular service uses “wsHttpBinding”.

No comments:

Post a Comment