2012-08-29 30 views
0

我成功添加一個服務引用到我的ASP.NET項目時,但我得到一個EndpointNotFoundException,當我嘗試從服務客戶端調用一個方法:EndpointNotFoundException調用服務

BenchmarkManagementServiceClient client = new BenchmarkManagementServiceClient(); 
try { 
    int id = Convert.ToInt32(userId); 
    if (client.VerifyUser(id)) { //Here is the exception thrown 
     FormsAuthentication.SetAuthCookie(userId, false); 
    } 
} catch (FormatException) { } 
client.Close(); 

那是好奇,因爲我可以通過瀏覽器訪問該服務的地址,並且可以在另一個項目(Windows窗體)中使用幾乎相同的代碼。

感謝您的幫助。

編輯:

的內部異常的消息是The remote name could not be resolved

我試圖請求服務在Azure的雲上運行。
ASP.NET項目在我的電腦上本地運行。
我的其他項目(一切工作正常)也在我的電腦上本地運行。

也許很高興知道,我必須創建服務引用,而不需要包Newtonsoft.Json。其他人在代碼生成過程中發現了服務引用的警告。

+0

可能是防火牆/防病毒問題。 –

+0

我不這麼認爲,因爲它適用於我的其他項目。我的ASP.NET項目在同一臺機器上本地測試 – Lennart

+0

http://stackoverflow.com/a/2288243/1262700可能會幫助你。 –

回答

3

我是在代理的背後,有完全相同的問題。

將此部分添加到我的配置中爲我修復了代理驗證錯誤。

<system.net> 
    <defaultProxy useDefaultCredentials="true" /> 
</system.net> 
+1

請考慮在評論框中輸入評論,而不是回答 – user1211929