的錯誤是很清楚 - 你'使用HTTP,你已經在你的ServiceMetadata行爲上啓用了HttpGetEnabled,但是你沒有在你的配置中提供一個基地址。
在IIS中,由於* .svc文件的位置定義了您的服務地址,所以既不需要也不使用基址。當您自行託管時,您可以並應該使用基地址。
更改你的配置看起來是這樣的:
<system.serviceModel>
<services>
<service name="YourService">
<host>
<baseAddresses>
<add baseAddress="http://localhost:8080/YourService" />
</baseAddresses>
</host>
<endpoint address="mex" binding="mexHttpBinding"
contract="IMetadataExchange" />
..... (your own other endpoints) ...........
</service>
</services>
</system.serviceModel>
現在,「HttpGetEnabled」有基址http://localhost.8080/YourService
去擺脫的元數據。
或者,如果你不喜歡這一點,再次,該錯誤信息是你選擇的很清楚:定義一個絕對URL在您ServiceMetadata的HttpGetUrl:
<serviceBehaviors>
<behavior name="Default">
<serviceMetadata
httpGetEnabled="true"
httpGetUrl="http://localhost:8282/YourService/mex" />
</behavior>
</serviceBehaviors>
客戶可以從中獲取元數據您的「mex」端點,或者在第二個示例中定義的固定URL處,或者它們將轉到元數據服務的基地址(如果有的話)。
如果你從IIS來了,還沒有適應任何東西,你既沒有基址,也不是爲你的元數據交換終結的明確,絕對URL,所以這就是爲什麼你得到你所看到的錯誤。
馬克
什麼是你的代碼創建代理? – Dani 2009-11-01 21:51:31
productsServiceHost = new ServiceHost(typeof(Products.ProductsService)); productsServiceHost.Open(); stop.IsEnabled = true; start.IsEnabled = false; status.Text =「服務正在運行...」; – Attilah 2009-11-01 22:00:44