I have Web application and android application which are communicating with Wcf Services. One of my Service is Chat.svc
[ServiceContract(Namespace = "http://webchat.com")]
public interface IChat
{
[OperationContract]
[WebInvoke(Method = "POST",
ResponseFormat = WebMessageFormat.Json,
RequestFormat = WebMessageFormat.Json,
BodyStyle = WebMessageBodyStyle.Wrapped,
UriTemplate = "Start")]
StartChatResult StartChat(StartChatEntity sce);
}
和Chat.svc.cs 和Chat.svc.cs 和Chat.svc.cs 和Chat.svc.cs 和Chat.svc.cs 和Chat.cs 和Chat.svc.cs
public StartChatResult StartChat(StartChatEntity sce)
{
//doing something else
List<tblChatRoom> list = ChatManager.GetChatRoomList();
return new StartChatResult() { IsSuccess = true, ChatRooms = list };
}
而这方法来自我的聊天管理者班
public static List<tblChatRoom> GetChatRoomList()
{
SessionDBDataContext db = new SessionDBDataContext();
return db.tblChatRooms.ToList();
}
当我从Android一侧打电话给 StartChat 方法时, 总是有一个“ 错误请求” 的响应。 当我评论这条线时
List<tblChatRoom> list = ChatManager.GetChatRoomList();
i m having "Ok", no problem. There is a problem in this line. Also SessionDBDataContext class is
[global::System.Data.Linq.Mapping.DatabaseAttribute(Name="SessionDB")]
public partial class SessionDBDataContext : System.Data.Linq.DataContext
{
private static System.Data.Linq.Mapping.MappingSource mappingSource = new AttributeMappingSource();
public SessionDBDataContext() :
base(global::System.Configuration.ConfigurationManager.ConnectionStrings["SessionDBConnectionString"].ConnectionString, mappingSource)
{
OnCreated();
}
public SessionDBDataContext(string connection) :
base(connection, mappingSource)
{
OnCreated();
}
public SessionDBDataContext(System.Data.IDbConnection connection) :
base(connection, mappingSource)
{
OnCreated();
}
public SessionDBDataContext(string connection, System.Data.Linq.Mapping.MappingSource mappingSource) :
base(connection, mappingSource)
{
OnCreated();
}
public SessionDBDataContext(System.Data.IDbConnection connection, System.Data.Linq.Mapping.MappingSource mappingSource) :
base(connection, mappingSource)
{
OnCreated();
}
public System.Data.Linq.Table<tblChatRoom> tblChatRooms
{
get
{
return this.GetTable<tblChatRoom>();
}
}
public System.Data.Linq.Table<tblTalker> tblTalkers
{
get
{
return this.GetTable<tblTalker>();
}
}
public System.Data.Linq.Table<tblSession> tblSessions
{
get
{
return this.GetTable<tblSession>();
}
}
public System.Data.Linq.Table<tblMessagePool> tblMessagePools
{
get
{
return this.GetTable<tblMessagePool>();
}
}
}
我认为会话 DB.dbml 有问题, 但如果我使用非服务方法的方法来编制聊天室列表, 也没关系 。 我无法理解在服务中调用时有什么不对 。 pls help