[英]Unexpected error when calling Weather Web Service from a Web Form
[英]Web service error when invoked from web form
我有一个利用Web服务的程序。 当单独测试该Web服务(在AS .asmx上运行)运行良好时,但是尝试从Web表单内部进行调用时,会产生以下错误:
客户发现响应内容类型为'text / html; charset = utf-8”,但预期为“ text / xml”。
Web服务是:
public Check1 () {
//Uncomment the following line if using designed components
//InitializeComponent();
}
[WebMethod]
public void check2(string destination)
{
Server.Transfer(destination);
}
}
从中调用的Web表单是:
protected void Button1_Click1(object sender, EventArgs e)
{
localhost.Check1 new2 = new localhost.Check1();
new2.check2("Ipal_apoth_page.aspx");
}
Web服务旨在用作数据接口,而不是网页服务器,这就是为什么需要XML的原因。 Web服务协议使用XML格式进行通信,例如WSDL或SOAP。 您尝试将处理转移到的.aspx页面将返回HTML。
可能是因为当您在浏览器中尝试过该浏览器时,该浏览器已足够让您以您想要的方式来解释来自Web服务的答复,即使这并非本意。
更好的做法是将两个数字相加,这很简单。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.