我一直在尝试关注有关从移动设备与WCF服务进行通信的this文章(使用紧凑型框架3.5)。我在桌面上运行了服务,它告诉我它正在运行:
http://localhost:1414/MyService.svc
我可以在我的客户端看到这个,但是当我尝试访问它时,我收到了这个错误:
There was no endpoint listening at http://localhost:1414/MyService.svc that could accept the message. This is often caused by an incorrect address or SOAP action. See InnerException, if present, for more details.
所以我做了:
InnerException: {"No connection could be made because the target machine actively refused it"}
我正在从模拟器运行,文章声称这不起作用 - 因此我怀疑我遇到了同样的问题。所以我的问题是,有谁知道为什么会出现这个问题?
编辑:
只是为了澄清,这在部署到设备时工作正常。这只是模拟器有问题。
编辑:
感谢@Shiraz Bhaiji我现在已经取得了一些进展,但我现在收到了错误:
CFFaultException
这似乎是我能得到的唯一错误信息,它是由电话引起的:
MyServiceServiceClient client = new MyServiceServiceClient(binding, endpoint);
returnString = client.MyFunc1();
我已将端点更改为引用我的I.P.直接解决如下(WCF服务在我的PC上运行):
Binding binding = MyServiceServiceClient.CreateDefaultBinding();
string remoteAddress = MyServiceServiceClient.EndpointAddress.Uri.ToString();
EndpointAddress endpoint = new EndpointAddress("http://1.1.1.1/MyService/MyService.svc");
答案 0 :(得分:2)
尝试将localhost
更改为您计算机的实际名称。
答案 1 :(得分:2)
在此链接上查看Eric Schneider的答案:http://social.msdn.microsoft.com/Forums/en/netfxcompact/thread/b5be4c83-40ca-423b-9068-8614779fed5f
使用IP地址连接服务器。