WCF服务抛出NetDispatcherFaultException

时间:2011-04-21 02:15:41

标签: javascript wcf

我面临着ASP.NET AJAX的WCF服务的问题。我编写了一个静态calss来维护WCF端的状态并从javaScript中测试它。我正在做的是以下步骤;

in $(document).ready(),

  1. 检查状态中的“CurrentUser”对象
  2. 如果返回值为NULL,则获取具有给定ID的用户并将其置于State。
  3. 重新加载页面或移动另一页。这是为了测试状态duting页面重新加载或移动 到另一页。
  4. 现在的症状是,我正在调用一个方法(GetFromState())来获取状态值。这适用于替代周期。意思是,第一次页面加载它工作,第二页它不会,并且第三次它工作。

    例外是;

      

    格式化程序在尝试反序列化消息时抛出异常:尝试反序列化参数ProjectDocs时出错:pStateKey。 InnerException消息是'反序列化System.String类型的对象时出错。令牌':'是预期的,但找到','。'。有关更多详细信息,请参阅InnerException。**

    类型 System.ServiceModel.Dispatcher.NetDispatcherFaultException

    我在web.config中启用了WCF登录,并检索了我传递的消息。消息如下;

      

    <MessageLogTraceRecord>
    <HttpRequest xmlns="http://schemas.microsoft.com/2004/06/ServiceModel/Management/MessageTrace">
    <Method>POST</Method>
    <QueryString></QueryString>
    <WebHeaders>
    <Cache-Control>no-cache</Cache-Control>
    <Connection>Keep-Alive</Connection>
    <Content-Length>73</Content-Length>
    <Content-Type>application/json; charset=utf-8</Content-Type>
    <Accept>*/*</Accept>
    <Accept-Encoding>gzip, deflate</Accept-Encoding>
    <Accept-Language>en-us</Accept-Language>
    <Cookie>ASP.NET_SessionId=gg53gxmy3pkqrabtr0czvnsx</Cookie>
    <Host>localhost:1496</Host>
    <Referer>http://localhost:1496/Admin/RoleManagement.aspx</Referer>
    <User-Agent>Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1; Trident/5.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C; .NET4.0E; InfoPath.3; BOIE9;ENIN)</User-Agent>
    <x-requested-with>XMLHttpRequest</x-requested-with>
    </WebHeaders>
    </HttpRequest>
    <root type="object" xmlns="">
    <pStateKey type="string">0c354a4f-cdaa-08cd-8c86-c1e06bec6b8d</pStateKey>
    <pKey type="string">CurrentUser</pKey>
    </root>
    </MessageLogTraceRecord>
    

    我正在使用的javaScript代码如下;

     $(document).ready(function () {
            var stateKey = GetStateKey();
    
            ProjectDocs.StateActions.GetFromState(stateKey.trim(), 'CurrentUser', function (result, e) {
                if (result != null && result.Code != null && result.Code != '') {
                    $get('<%=CurrentUser.ClientID %>').value = result;
    
                }
                else {//Redirect to login page
                    //For time being
                    var curUser = ProjectDocs.UserActions.GetUserDetails('31534974-c759-08cd-5e8b-8dd0045a6b25', function (result, e) {
                        $get('<%=CurrentUser.ClientID %>').value = result;
                        AddToState('CurrentUser', result);
                        alert(result.Code);
    
                    }, function (result, e) { N_NotifyMessage('Unable to get user details.', result.get_message(), 2); });
                }
            }, function (result, e) {
                //Redirect ro login page
    
                N_NotifyMessage(GetStateKey(), result.get_message(), 2);
            });
        });  
    

    最后......请帮我解决这个问题......

    提前致谢, Pradeep Yamujala

1 个答案:

答案 0 :(得分:0)

看起来您放置的消息跟踪是为了成功调用。你有一个失败的电话跟踪

相关问题