【问题标题】:WCF Service WindowsPhone - EndpointNotFoundExceptionWCF 服务 WindowsPhone - EndpointNotFoundException
【发布时间】:2012-02-14 09:49:53
【问题描述】:

我正在 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 应用程序不能。

【问题讨论】:

    标签: wcf windows-phone


    【解决方案1】:

    我假设这是您的客户端配置,例如电话。您指向本地主机,但由于您在手机上的模拟器中,本地主机解析为相同,而不是托管服务的 PC。

    address="http://localhost:2395/MyCustomService.svc" 
    

    把你电脑的主机名放在那里,你应该没问题

    【讨论】:

    • 不幸的是不起作用。我什至把它放在互联网上。抛出 EndpointNotFound 异常。 (它也发生在模拟器和设备上)
    【解决方案2】:

    嗯,我不知道它是如何开始工作的,但确实如此。我将我的服务上传到互联网托管,并从我的手机客户端项目中删除所有服务引用,并使用互联网地址再次添加它们,它现在可以工作了。谢谢你的帮助多米尼克。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-02-07
      • 2015-06-11
      • 1970-01-01
      • 1970-01-01
      • 2014-01-02
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多