【发布时间】:2019-11-06 23:54:36
【问题描述】:
我必须在 Xamarin 项目中实现 Web 服务。 所以我创建了一个简单的 Web 服务来做一些测试。有我以前用的代码:
using (HttpClient client = new HttpClient()) {
client.BaseAddress = new Uri("http://localhost:62056/");
client.DefaultRequestHeaders.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json"));
HttpResponseMessage response = client.GetAsync("DataTransferTest.svc/HelloWorld").Result;
string json = response.Content.ReadAsStringAsync().Result;
}
我已经尝试将http://localhost:62056/ 更改为http:10.0.0.2:62056,但没有任何改变。
我已经像这样配置我的 ISS express 了:
<site name="LogiStock.WebServices2" id="4">
<application path="/" applicationPool="Clr4IntegratedAppPool">
<virtualDirectory path="/" physicalPath="D:\TeamExplorer\LogiStock-1.0.1\LogiStock.WebServices2" />
</application>
<bindings>
<binding protocol="http" bindingInformation="*:62056:localhost" />
<binding protocol="http" bindingInformation="*:62056:192.168.90.139" />
<binding protocol="http" bindingInformation="*:62056:127.0.0.1" />
</bindings>
</site>
我在尝试这段代码时遇到了错误:
发生了一个或多个错误。发送请求时出错 _错误:连接失败(连接被拒绝)_连接被拒绝
真的希望有人能帮帮我,我真的不知道哪里错了..
【问题讨论】:
-
你错过了你的网址
http:10.0.0.2:62056的“//”吗? -
不,我把它们放到我的网址中
标签: android web-services wcf xamarin