此代码是将事件导出到Google日历,在本地工作正常,但是在IIS服务器中上载服务后,出现此异常。System.ServiceModel.ProtocolException:'内容类型为text / html;响应消息的charset = utf-8与绑定的内容类型不匹配(文本/ XML; charset = utf-8)。
public partial class UNGCCalendarEvent : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button 1_Click(object sender, EventArgs e)
{
// WCFServiceClient client = new WCFServiceClient();
using (UNGCCalenderSoapClient uNGC = new UNGCCalenderSoapClient())
{
uNGC.Endpoint.Binding.SendTimeout = new TimeSpan(0, 2, 30);
// EntityExtractionClient nlp = new EntityExtractionClient();
uNGC.InnerChannel.OperationTimeout = new TimeSpan(0, 50, 0);
string EventSummary = TextSumary.Text.ToString();
string EventLocation = TextLocation.Text.ToString();
string EventDescription = TextDescription.Text.ToString();
string EventStartDateTime = TextStartDate.Text.ToString();
string EventEndDateTime = TextEndDate.Text.ToString();
string CustomCalenderName = TextCustomCalenderName.Text.ToString();
string StartDatetimeZone = TextStartDatetimeZone.Text.ToString();
string EndDatetimeZone = TextEndDatetimeZone.Text.ToString();
string[] attendees = Textattendees.Text.Split(',');
var a = new ArrayOfString { Textattendees.Text };
string attachmentsfileUrl = TextattachmentsfileUrl.Text.ToString();
//string s = new string(attendees);
//string a = uNGC.UNGCCalenderService(EventSummary, EventLocation, EventDescription, Convert.ToDateTime(EventStartDateTime), Convert.ToDateTime(EventEndDateTime));
string calendar = uNGC.ExportGoogleEvents(EventSummary, EventLocation, EventDescription, Convert.ToDateTime(EventStartDateTime), Convert.ToDateTime(EventEndDateTime), CustomCalenderName, StartDatetimeZone, EndDatetimeZone, attachmentsfileUrl, a);
uNGC.Close();
}
}
protected void BtnUpdate_Click(object sender, EventArgs e)
{
UNGCCalenderSoapClient uNGC = new UNGCCalenderSoapClient();
// UNGCCalender arrString = UNGCCalenderSoapClient.ArrayOfString();
string EventID = TextEventID.Text.ToString();
string EventSummary = TextSumary.Text.ToString();
string EventLocation = TextLocation.Text.ToString();
string EventDescription = TextDescription.Text.ToString();
string EventStartDateTime = TextStartDate.Text.ToString();
string EventEndDateTime = TextEndDate.Text.ToString();
string CustomCalenderName = TextCustomCalenderName.Text.ToString();
string StartDatetimeZone = TextStartDatetimeZone.Text.ToString();
string EndDatetimeZone = TextEndDatetimeZone.Text.ToString();
string[] attendees = Textattendees.Text.Split(',');
string attachmentsfileUrl = TextattachmentsfileUrl.Text.ToString();
//string s = new string(attendees);
//string a = uNGC.UNGCCalenderService(EventSummary, EventLocation, EventDescription, Convert.ToDateTime(EventStartDateTime), Convert.ToDateTime(EventEndDateTime));
// string calendar = uNGC.UpdateGoogleEvents(EventID,EventSummary, EventLocation, EventDescription, Convert.ToDateTime(EventStartDateTime), Convert.ToDateTime(EventEndDateTime), CustomCalenderName, StartDatetimeZone, EndDatetimeZone, attachmentsfileUrl, arrString.AddRange(attendees));
}
}