简体   繁体   中英

Having trouble connecting to wcf service on localhost from Android emulator

I'm building an app with Xamarin Studio that's supposed to access a wcf service. Accessing the service works fine from my browser with the following url: http://localhost:52277/api

Whenever I try to access it from my android code, I get the following exception:

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

I'm running the service on IIS express, and I've modfied my iis applicationhost.config like this (Removing 'localhost' from bindingInformation, according to a course on pluralsight):

<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>

Also, my web service is building and deploying using iis express at the mentioned port. Any suggestions to what I might be doing wrong? :)

通过使用以下ip解决:10.0.2.2而不是localhost。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM