我创建了一个WCFService Library,我想在其中插入并从XML获取数据。
我的服务:
using System.ServiceModel;
namespace WcfServiceLibrary1{
[ServiceContract]
public interface IService1
{
[OperationContract]
void InsertData(string Name, string Email, string Message);
}
}
我的服务类:
using System.Web;
using System.Xml.Linq;
namespace WcfServiceLibrary1{
public class Service1 : IService1
{
public void InsertData(string Name, string Email, string Message)
{
XDocument xmldoc = XDocument.Load(HttpContext.Current.Server.MapPath("DataFile.xml"));
xmldoc.Element("root").Add(
new XElement("User",
new XAttribute("Name", Name),
new XAttribute("Email", Email),
new XAttribute("Message", Message)));
xmldoc.Save(HttpContext.Current.Server.MapPath("DataFile.xml"));
}
}
}
我对WCF很新。当我运行它并调用我的insert()
时,会出现以下异常:
答案 0 :(得分:1)
为什么不包括MessageLogging和Tracing,看看会发生什么?