tags:

views:

53

answers:

0

I am trying to setup an ASPX page to call a WCF servcie thorugh a ScriptManager. For some reason when I call the "SpinStitch.Services.Chat.IChatter.CreateChatSession" method of the servcie I get this error "The server method 'CreateChatSession' failed.' I had a breakpoint set on the CreateChatSession method in the server, but it never gets that far. I am not sure what I have setup wrong. I have looked at 100 samples of how to set this up and they all look about the same. Jsut noe the <%=ChatSessionObject %> property is coming from the ASPX code behind and is creating a JSON serialized object. Any thoughts?

Interface:
using System.ServiceModel;
using System.ServiceModel.Web;
namespace SpinStitch.Services.Chat
{
    [ServiceContract(Namespace = "SpinStitch.Services.Chat")]
    public interface IChatter
    {

        [OperationContract]
        bool CreateChatSession(Domain.Objects.ChatSession chat);

    }

}

Service:
using System.ServiceModel.Activation;
using SpinStitch.Domain.Adapters;

namespace SpinStitch.Services.Chat
{
    [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
    public class Chatter : IChatter
    {

        public bool CreateChatSession(Domain.Objects.ChatSession chat)
        {
            return ChatSessionAdapter.CreateChatSession(chat) > 0;
        }
    }

}

Web.Config of hosted service:
<system.serviceModel>

    <behaviors>
      <endpointBehaviors>
        <behavior name="ChatBehaviorConfig">
          <enableWebScript/>         
        </behavior>

      </endpointBehaviors>
      <serviceBehaviors>
               <behavior name="ChatBehavior">
          <serviceMetadata httpGetEnabled="true"/>
          <serviceDebug includeExceptionDetailInFaults="true"/>

        </behavior>

      </serviceBehaviors>
     </behaviors>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true">
    </serviceHostingEnvironment>

    <services>

      <service behaviorConfiguration="ChatBehavior" name="SpinStitch.Services.Chat.Chatter">
        <endpoint address="http://servicesdev.spinstitch.com/Chat.svc" binding="webHttpBinding" behaviorConfiguration="ChatBehaviorConfig"  bindingConfiguration="" name="Chat" contract="SpinStitch.Services.Chat.IChatter" />
      </service>
     </services>
    </system.serviceModel>

Web Config of Ajax App:
<system.serviceModel>
    <bindings>
      <customBinding>
        <binding name="Chat">
          <textMessageEncoding maxReadPoolSize="64" maxWritePoolSize="16"
            messageVersion="Soap12" writeEncoding="utf-8">
            <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
              maxBytesPerRead="4096" maxNameTableCharCount="16384" />
          </textMessageEncoding>
        </binding>
      </customBinding>
          </bindings>
    <client>
           <endpoint binding="customBinding" bindingConfiguration="Chat"
        contract="ServicesDevChat.IChatter" name="Chat" />
    </client>
  </system.serviceModel>


ASPX:
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="AnonymousUser.aspx.vb" Inherits="TestArea_ChatTest_AnonymousUser" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;

<html xmlns="http://www.w3.org/1999/xhtml"&gt;
<head runat="server">
    <title></title>
</head>
<script language="javascript" type="text/javascript">
function pageLoad() {
    var chatSession = <%=ChatSessionObject %>
    SpinStitch.Services.Chat.IChatter.CreateChatSession(chatSession, OnRetrieveLoadData, failed)
}

function OnRetrieveLoadData(recordInserted) {
    alert(recordInserted)
}

function failed(sender, e) {
    alert(sender._message);
}
</script>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:ScriptManager ID="ScriptManager1" runat="server">
        <Services>
            <asp:ServiceReference Path="http://servicesdev.spinstitch.com/chat.svc" />
        </Services>

        </asp:ScriptManager>



    </div>
    </form>
</body>
</html>