2009-11-23 4 views
0

Je suis en train de configurer une page ASPX pour appeler un servcie WCF répercutant un ScriptManager. Pour une raison quelconque quand je l'appelle la méthode « SpinStitch.Services.Chat.IChatter.CreateChatSession » du servcie je reçois cette erreur « La méthode du serveur « CreateChatSession » échoué « . J'ai eu un point d'arrêt défini sur la méthode de CreateChatSession dans le serveur, mais il ne fait jamais jusque-là. Je ne sais pas ce que j'ai installé mal. Je l'ai regardé 100 échantillons de la façon de mettre en place et ils se ressemblent tous de la même chose. jsut noe le <% = ChatSessionObject%> propriété provient du code ASPX derrière et crée un objet sérialisé JSON. Toute pensée?Aide avec WCF dans servcie applicaiton web AJAX envoyer JSON

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"> 

<html xmlns="http://www.w3.org/1999/xhtml"> 
<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> 

Répondre

0

Ce service n'a pas becuase était en cours d'exécution dans un do séparé principale. Sous .Net 3.5, vous ne pouviez pas traverser les domaines. Merci à tous pour regarder!

0

Il ne ressemble pas à ChatSession est un objet DataContract/DataMember. il semble plutôt comme un pur objet de script de quelque sorte. est-ce exact? Si oui, c'est probablement pourquoi l'opération échoue.

+0

En fait, il a échoué parce que le service était en cours d'exécution dans un domaine distinct et qui était un No-No à 3.5 Maintenant, la version 4.0, vous pouvez passer d'un domaine. Je posterai ceci comme réponse. – DDiVita