programmerist 1983
asked on
How to optimize Fluent Interface in Web services?
it is my mail class which is a model:
Cannot serialize member System.ComponentModel.Mars halByValue Component. Site of type System.ComponentModel.ISit e because it is an interface.
How to solve it?
public class Mail
{
public MailService Set { get; set; }
public string UserName { get; set; }
public string Password { get; set; }
public string Subject { get; set; }
public string Body { get; set; }
public List Recipients { get; set; }
public List Bcc { get; set; }
public List Cc { get; set; }
public bool Send { get; set; }
public Mail()
{
Set = new MailService(this);
}
}
Also i created a web service which is controller :namespace MyFluentInterface.Services
{
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)]
// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
// [System.Web.Script.Services.ScriptService]
public class MailService : System.Web.Services.WebService
{
[NonSerialized]
private readonly Mail _mail;
public MailService()
{
}
public MailService(Mail mail)
{
_mail = mail;
}
#region IMail Members
[WebMethod]
public MailService UserName(string username)
{
_mail.UserName = username;
return this;
}
[WebMethod]
public MailService Password(string password)
{
_mail.Password = password;
return this;
}
[WebMethod]
public MailService Subject(string subject)
{
_mail.Subject = subject;
return this;
}
[WebMethod]
public MailService Body(string body)
{
_mail.Body = body;
return this;
}
[WebMethod]
public MailService Recipients(List recipients)
{
_mail.Recipients = recipients;
return this;
}
[WebMethod]
public MailService Bcc(List bcc)
{
_mail.Bcc = bcc;
return this;
}
[WebMethod]
public MailService Cc(List Cc)
{
_mail.Cc = Cc;
return this;
}
[WebMethod]
public bool Send()
{
_mail.Send = true; // Bir olayin sonucunda bu elde edilmeli
return true;
}
#endregion
}
}
Also i have a VIEW project to test: public class Test
{
private Mail mail { get; set; }
public Test()
{
mail = new Mail();
}
public bool Send()
{
return mail.Set.Subject("fdsfs").Body("fsdg").Send();
}
}
i utilize from Fluent interface.i used it in web service. But this error returns me:Cannot serialize member System.ComponentModel.Mars
How to solve it?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
ARE YOU THERE????????????????????? ????? i want to see answer . i wont refresh my subscribe
ASKER