WCF listen base address anyip

天涯浪子 提交于 2019-12-10 19:58:36

问题


i want my servicehost to have the base address of any IP so i tried this

new ServiceHost(typeof(LoggingController),new Uri("0.0.0.0"));

and it gives me invalid URI format

any one knows how should i write this ?

well i tried to access it from outside of my local lan and it didnt work , i made a small test software using tcpiplistener and i started listening to the same port and i set the base address of the tcpip protocol to anyip and the small test software worked so i figured out all i need to do is setting the same for the Webservice –

TcpListener tcpListener = new TcpListener(IPAddress.Any,10021);

this works which also mean my system admin did his job of making sure the port/server is accessable from outside, now shouldnt my webservice work !? it work but i cant access it from outside , i can access it from the same pc if i run client on the same pc


回答1:


The following code works for me in a similar situation:

Uri baseAddress = new Uri("net.tcp://0.0.0.0:8080/MyService");
host = new ServiceHost(typeof(MyServer), baseAddress);



回答2:


Reminds me of a problem we had with our software. The default configuration of the webservice used windows network credentials to apply message based security which - due to the domain/network credentials - won't work from another network. Our solution was to disable security on the service binding (which may be a bit tricky depending on the binding you use). For the default bindings like WebHttpBinding it's just passing a parameter in the constructor. Hope this helps!



来源:https://stackoverflow.com/questions/3434216/wcf-listen-base-address-anyip

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!