的错误是很清楚 - 你'使用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