WCF按照basicHttpBinding方式发布,.net按照Web Service方式调用,自动生成的Proxy中枚举类型和Nullable类型的参数,在Proxy里面发现一些不一样的东西,都额外生成一个配对的XXSpecified的字段和属性。你必须将该值设为true,否则,WCF序列化的时候回忽略相应的枚举类型或Nullable类型,全部使用的默认值,你所赋的值都被忽略了,只有你将XXSpecified设置为true就可以了。
WCF按照basicHttpBinding方式发布,.net按照Web Service方式调用,自动生成的Proxy中枚举类型和Nullable类型的参数,在Proxy里面发现一些不一样的东西,都额外生成一个配对的XXSpecified的字段和属性。你必须将该值设为true,否则,WCF序列化的时候回忽略相应的枚举类型或Nullable类型,全部使用的默认值,你所赋的值都被忽略了,只有你将XXSpecified设置为true就可以了。
Code
[TestMethod]
public void TestASMXSendHtmlMail()
{
localhost.TencentEmail mail = new localhost.TencentEmail();
mail.EmailType = localhost.TencentMailType.SEND_TO_MEETING;
mail.EmailTypeSpecified = true;
mail.To = "toby";
mail.From = "geffzhang";
mail.CC = "mouse";
mail.Bcc = "geffzhang";
mail.Title = "this's a test mail ";
mail.Content = "<H1>this's a test meeting mail. </H1>";
mail.BodyFormat = localhost.TencentMailFormat.Html;
mail.BodyFormatSpecified = true;
mail.Priority = localhost.MessagePriority.Hight;
mail.PrioritySpecified = true;
mail.Organizer = "geffzhang";
mail.Location = "飞亚达1003";
mail.StartTime = DateTime.Now;
mail.StartTimeSpecified = true;
mail.EndTime = DateTime.Now.AddDays(1);
mail.EndTimeSpecified = true;
localhost.MessageService messageService = new localhost.MessageService();
messageService.Application_Context = new localhost.ApplicationContext() { AppKey = "93ed11c73f7c4ae7a6335ffa9809e4f9" };
bool sendResult;
bool sendResultSpec;
messageService.SendMail(mail, out sendResult, out sendResultSpec);
Assert.IsTrue(sendResult);
}