WCF配置指定Address具體實(shí)現(xiàn)方法介紹
在對(duì)WCF進(jìn)行實(shí)際操作時(shí),對(duì)于Address的相關(guān)應(yīng)用是一個(gè)非常重要的操作技術(shù)。那么我們今天將會(huì)在這篇文章中,為大家詳細(xì)介紹一下有關(guān)WCF配置指定Address的相關(guān)實(shí)現(xiàn)技巧,希望能給大家?guī)?lái)一些幫助。
相對(duì)地址
- < host>
- < baseAddresses>
- < add baseAddress = "http://localhost:8731/" />
- < /baseAddresses>
- < /host>
- < endpoint address ="Service1" binding="basicHttpBinding"
contract="Wcf_Address_Config.IService1">< /endpoint>
這個(gè)WCF的實(shí)際地址:
http://localhost:8731/Service1
絕對(duì)地址
- < host>
- < baseAddresses>
- < add baseAddress = "http://localhost:8731/" />
- < /baseAddresses>
- < /host>
- < endpoint address ="http://localhost:8731/Service"
binding="basicHttpBinding" contract="Wcf_Address_Config.IService1">
< /endpoint>
是絕對(duì)地址的時(shí)候,baseAddresses就不起作用了,實(shí)際地址就是endpoint中設(shè)置的地址
在網(wǎng)上有人說(shuō)絕對(duì)地址是通過(guò)將httpGetEnabled設(shè)置為true,并且設(shè)置httpGetUrl為絕對(duì)地址是在設(shè)置endPoint的說(shuō)法有些不準(zhǔn)確,因?yàn)樵赪CF中有兩種地址,一種是訪問(wèn)endPoint時(shí)候用到地址,另外一種是服務(wù)描述的地址,服務(wù)描述在wcf中被稱作serviceMetadata,通過(guò)它能夠產(chǎn)生代理類,比如,我們做如下的設(shè)置:
- < serviceMetadata httpGetEnabled="True"
httpGetUrl="http://localhost:8731/Service"/>
只代表在http://localhost:8731/Service/?wsdl上能找到服務(wù)描述,可以通過(guò)http://localhost:8731/Service/?wsdl生成代理類,而不是將endPoint的地址設(shè)置為了http://localhost:8731/Service,這點(diǎn)一定要注意,不要受有些說(shuō)法的誤導(dǎo)。
【編輯推薦】