我一直在尝试关注this有关从移动设备与 WCF 服务进行通信的文章(使用紧凑框架 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();
我已更改端点以引用我的 IP。直接地址如下(WCF服务此时正在我的PC上运行):
Binding binding = MyServiceServiceClient.CreateDefaultBinding();
string remoteAddress = MyServiceServiceClient.EndpointAddress.Uri.ToString();
EndpointAddress endpoint = new EndpointAddress("http://1.1.1.1/MyService/MyService.svc");
最佳答案
查看 Eric Schneider 在此链接上的回答:http://social.msdn.microsoft.com/Forums/en/netfxcompact/thread/b5be4c83-40ca-423b-9068-8614779fed5f
使用 IP 地址连接到服务器。
关于从紧凑框架调用 WCF 服务,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4819942/