![](/img/trans.png)
[英]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.