我正在WCF服务和Windows Phone客户端应用程序中开发解决方案。问题是我无法连接到服务,即使是在模拟器中,当我在Internet Explorer中键入服务的地址时,我会得到正确的结果。我的配置文件:
<configuration>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IMyCustomService"
maxReceivedMessageSize="2147483647"
maxBufferSize="2147483647"
enableHttpCookieContainer="true"
/>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost:2395/MyCustomService.svc"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IMyCustomService"
contract="MyService.IMyCustomService" name="BasicHttpBinding_IMyCustomService" />
</client>
</system.serviceModel>
</configuration>我的服务接口:
[ServiceContract]
[ServiceKnownType(typeof(CustomResponse))]
public interface IMyCustomService
{
[OperationContract]
CustomResponse GetData();
}我的问题是,每次我尝试调用客户端代理GetDataAsync()方法时,完成的事件都不会被触发,并且我得到"EndpointNotFoundException“。我已经尝试了我找到的所有解决方案,但没有一个对我有帮助。我也尝试制作WPF测试客户端,它可以正常工作,但Windows Phone应用程序不能。
发布于 2012-02-14 21:20:12
我假设这是您的客户端配置,例如电话。您指向的是localhost,但由于您在手机上的模拟器中,localhost解析到的是相同的内容,而不是托管服务的PC。
address="http://localhost:2395/MyCustomService.svc" 把你电脑的主机名放进去,你就没问题了。
发布于 2012-02-15 17:14:54
嗯,我不知道它是怎么开始工作的,但它确实起作用了。我上传我的服务到互联网主机,从我的手机客户端项目中删除所有服务引用,并再次添加它们与互联网地址,它现在工作。谢谢你的帮助Dominik。
https://stackoverflow.com/questions/9274776
复制相似问题