locked
ASP.NET AJAX and WCF behaviorExtension problen RRS feed

  • Question

  • User991107785 posted

    I have simple wcf service with one operation: <service name="HelpService"> <endpoint address="" behaviorConfiguration="Services" binding="webHttpBinding" contract="IHelpService"> <behavior name="Services"> <enableWebScript> </enableWebScript></behavior></endpoint></service>

     <service name="HelpService"> <endpoint address="" behaviorConfiguration="Services" binding="webHttpBinding" contract="IHelpService" /> </service> <behavior name="Services"> <enableWebScript /> </behavior>


    <service name="HelpService"><endpoint address="" behaviorConfiguration="Services" binding="webHttpBinding" contract="IHelpService"><behavior name="Services"><enableWebScript>

    [WebInvoke(Method = "POST", ResponseFormat = WebMessageFormat.Json, RequestFormat = WebMessageFormat.Json)] [OperationContract]
    
    public string GetQuickHelp(string contentId)

    </enableWebScript></behavior></endpoint></service>

    <service name="HelpService"><endpoint address="" behaviorConfiguration="Services" binding="webHttpBinding" contract="IHelpService"><behavior name="Services"><enableWebScript>Service is used on client side over JQuery. All works ok without any problems. Then after reading a lot of articles about correct errors handling I have added behaviorExtension to subscribe error hanlder (like <service name="HelpService"><endpoint contract="IHelpService" binding="webHttpBinding" behaviorconfiguration="Services"><behavior name="Services"><enablewebscript>http://stackoverflow.com/questions/1272877/returning-error-details-from-ajax-enabled-wcf-service</enablewebscript></behavior></endpoint></service>).</enableWebScript></behavior></endpoint></service>

    <service name="HelpService"><endpoint address="" behaviorConfiguration="Services" binding="webHttpBinding" contract="IHelpService"><behavior name="Services"><enableWebScript>This have created problems for this method. Serialization of simple string parameter failed (behavior is derived from WebHttpBehavior without any additional logic except errorhandler subscribe). I have found that methods that accept complex parameters (like datacontract) works ok after adding it. But simple/primitive types - fails. As far as I could see this is connected with WebMessageBodyStyle. Of course I could provide correct value for every method (with simple parameter and complex) but such fix seem to me not so clever. Does anyone have ideas how to fix this? </enableWebScript></behavior></endpoint></service>

    Wednesday, April 14, 2010 2:47 PM

Answers

  • User991107785 posted

    problem seem to me located inside

    WebScriptEnablingBehavior.CreateDataContractJsonSerializerOperationFormatter

    custom behavior could not repeat this logic (it is internal method). And default logic just don't format correctly (using

    common ajax "d" style). I have no ideas how to fix this.

    This could be fixed if in web.config placing behavior extension before enablewebscript behaviour.  But in this case enablewebscript

    subscribe you error handler which completely broke custom error retrieve.


    Sometimes MSFT create architectures that is impossible to customize. 

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, April 15, 2010 4:10 AM