我正在使用 Xamarin Studio 构建一个应该访问 wcf 服务的应用程序。使用以下 url 从我的浏览器访问该服务可以正常工作:
http://localhost:52277/api
每当我尝试从我的 android 代码中访问它时,都会出现以下异常:
System.Net.WebException: Error: ConnectFailure (Connection refused) ---> System.Exception: Connection refused
at System.Net.Sockets.Socket.Connect (System.Net.EndPoint remoteEP) [0x00000] in <filename unknown>:0
at System.Net.WebConnection.Connect (System.Net.HttpWebRequest request) [0x00000] in <filename unknown>:0
--- End of inner exception stack trace ---
at System.Net.HttpWebRequest.EndGetResponse (IAsyncResult asyncResult) [0x00000] in <filename unknown>:0
at System.Net.HttpWebRequest.GetResponse () [0x00000] in <filename unknown>:0
at ServiceStack.ServiceClient.Web.ServiceClientBase.Send[String] (System.String httpMethod, System.String relativeOrAbsoluteUrl, System.Object request) [0x00051] in c:\Users\nicklas.winger\Documents\GitHub\ServiceStack\src\ServiceStack.Common\ServiceClient.Web\ServiceClientBase.cs:896
我在 IIS express 上运行该服务,并且像这样修改了我的 iis applicationhost.config(根据关于复数视力的课程,从 bindingInformation 中删除 'localhost'):
<site name="ProteinTrackerMvc" id="45">
<application path="/" applicationPool="Clr4IntegratedAppPool">
<virtualDirectory path="/" physicalPath="c:\users\nicklas.winger\documents\visual studio 2012\Projects\ProteinTrackerMvc\ProteinTrackerMvc" />
</application>
<bindings>
<binding protocol="http" bindingInformation="*:52277:" />
</bindings>
</site>
此外,我的 Web 服务正在上述端口使用 iis express 构建和部署。对我可能做错的事情有什么建议吗?:)