2010-04-21 77 views
2

當我試圖從Jquery調用簡單的webservice方法時,出現了一個奇怪的問題。從JQuery調用webservice時出錯

本地它工作正常,但在我的測試服務器上它沒有。

jQuery的請求是這樣的(只顯示實際的請求,而不是方法的其餘部分):當我從測試服務器能正常工作,裏面有我想知道運行這個本地

$.ajax({ 
    type: "POST", 
    url: "/Service/Service.asmx/AddTab", 
    data: "tab=" + element.innerHTML, 
    success: function(msg) { 
     alert('success'); 
    } 
}); 

如果這可能是我在IIS中遺漏的一些設置。

如果我導航到.asmx文件並單擊AddTab方法,我會得到SOAP 1.1和SOAP 1.2 XML列表,但不是HTTP POST請求。如果我瀏覽到在本地,我得到三個(SOAP 1.1,SOAP 1.2和HTTP POST)

該服務設置如下:

[WebService(Namespace = "mynamespace")] 
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)] 
[System.ComponentModel.ToolboxItem(false)] 
[ScriptService()] 
public class Service : System.Web.Services.WebService 
{ 

    [WebMethod(EnableSession=true)] 
    [ScriptMethod()] 
    public void AddTab(string tab) 
    { 
     //Some code to add a tab which evidently works locally... 
    } 

    } 

任何人有什麼線索,我在這裏失蹤?

+0

.NET和IIS版本? 您是否嘗試過在jQuery調用中設置contentType? – mamoo 2010-04-21 08:04:08

+0

3.5,IIS 7和是的,它在本地工作正常......並在本地測試服務器上以及...有或沒有contentType – Robban 2010-04-21 08:07:06

回答

2

管理通過向最終解決這個以下到web-配置:

<webServices> 
    <protocols> 
    <add name="HttpPost"/> 
    </protocols> 
</webServices> 

Appearently服務器擋住從遠程主機的進入請求。

1

確保web.config文件正確configured

+0

web.config外觀完全按照該帖子中的指定:/ – Robban 2010-04-21 08:09:21