相对地址
<host>
<baseAddresses>
<add baseAddress = "http://localhost:8731/" />
</baseAddresses>
</host>
<endpoint address ="Service1" binding="basicHttpBinding" contract="Wcf_Address_Config.IService1"></endpoint>
<baseAddresses>
<add baseAddress = "http://localhost:8731/" />
</baseAddresses>
</host>
<endpoint address ="Service1" binding="basicHttpBinding" contract="Wcf_Address_Config.IService1"></endpoint>
这个WCF的实际地址:
http://localhost:8731/Service1
绝对地址
<host>
<baseAddresses>
<add baseAddress = "http://localhost:8731/" />
</baseAddresses>
</host>
<endpoint address ="http://localhost:8731/Service" binding="basicHttpBinding" contract="Wcf_Address_Config.IService1"> </endpoint>
<baseAddresses>
<add baseAddress = "http://localhost:8731/" />
</baseAddresses>
</host>
<endpoint address ="http://localhost:8731/Service" binding="basicHttpBinding" contract="Wcf_Address_Config.IService1"> </endpoint>
是绝对地址的时候,baseAddresses就不起作用了,实际地址就是endpoint中设置的地址
在网上有人说绝对地址是通过将httpGetEnabled设置为true,并且设置httpGetUrl为绝对地址是在设置endPoint的说法有些不准确,因为在WCF中有两种地址,一种是访问endPoint时候用到地址,另外一种是服务描述的地址,服务描述在wcf中被称作serviceMetadata,通过它能够产生代理类,比如,我们做如下的设置:
<serviceMetadata httpGetEnabled="True" httpGetUrl="http://localhost:8731/Service"/>
只代表在http://localhost:8731/Service/?wsdl上能找到服务描述,可以通过http://localhost:8731/Service/?wsdl生成代理类,而不是将endPoint的地址设置为了http://localhost:8731/Service,这点一定要注意,不要受有些说法的误导。