0
我有Web應用程序和Android應用程序與Wcf服務進行通信。 我的服務之一是Chat.svc從Wcf服務連接到dbml
[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
public StartChatResult StartChat(StartChatEntity sce)
{
//doing something else
List<tblChatRoom> list = ChatManager.GetChatRoomList();
return new StartChatResult() { IsSuccess = true, ChatRooms = list };
}
從我ChatManager類
public static List<tblChatRoom> GetChatRoomList()
{
SessionDBDataContext db = new SessionDBDataContext();
return db.tblChatRooms.ToList();
}
這種方法當我打電話在Android爲startChat方法總是有一個「錯誤的請求」響應。當我採取評論此行
List<tblChatRoom> list = ChatManager.GetChatRoomList();
我有「好」,沒問題。這條線存在問題。 也SessionDBDataContext類是
[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>();
}
}
}
我想有一個與SessionDB.dbml一個問題,但是當我使用這不是服務方法有聊天室列表的方法,它是確定。我無法理解撥打服務時出現的問題。請幫助