2009-04-17 84 views
1

在MS的Visual Web Developer中,我有一個完全默認的ASP.NET Web服務項目和另一個項目。當使用右鍵菜單上的第二個項目運行「添加服務引用」,我能找到列爲選項的第一個項目,但我得到一個錯誤,當我嘗試選擇它,我得到一個錯誤「添加服務引用」失敗VS

 
Metadata contains a reference that cannot be resolved: 'http://0.0.0.0:3495/Service1.asmx?wsdl'. 
There was an error downloading 'http://0.0.0.0:3495/Service1.asmx?wsdl'. 
Unable to connect to the remote server 
The requested address is not valid in its context 0.0.0.0:3495 
Metadata contains a reference that cannot be resolved: 'http://localhost:3495/Service1.asmx'. 
Metadata contains a reference that cannot be resolved: 'http://localhost:3495/Service1.asmx'. 
If the service is defined in the current solution, try building the solution and adding the service reference again. 

我在使用WCF服務時也遇到同樣的問題。

我在做什麼錯?


我發現this referencethis service和事情的工作。 (WhyT_不默認服務只是工作?

回答

0

該服務需要可用。

如果你只是開始服務,添加服務引用應該工作。

+0

沒有喜悅,按Ctrl-F5似乎開始服務,但我仍然得到同樣的錯誤,如果只是F5變灰「添加服務」選項,並IIRC沒有工作,即使我在另一個VS會話中打開相同的解決方案。 – BCS 2009-04-17 21:53:14

+0

嗯......你可以嘗試使用IIS來調試你的服務,然後嘗試添加引用。 – 2009-04-17 21:55:32

2

由於沒有生成代理,因此未添加引用。

在我的情況下,我得到了「元數據包含無法解析的引用」,因爲合同中的暴露對象使用的某些內部類型是不可序列化的。

應用Serializable屬性後,代理正確生成並添加了引用。

因此,您可能想要檢查合約中暴露的類型是否可序列化。

1

該服務需要可供所有(匿名)用戶訪問。您可以訪問的位置使用:

<location path="YOURPATH" > 
    <system.web> 
    <authorization> 
     <allow users="*" /> 
    </authorization> 
    </system.web> 
</location>