Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/31.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 开发时使用WCF服务和Windows Phone应用程序_C#_Asp.net_Windows_Wcf_Windows Phone 7 - Fatal编程技术网

C# 开发时使用WCF服务和Windows Phone应用程序

C# 开发时使用WCF服务和Windows Phone应用程序,c#,asp.net,windows,wcf,windows-phone-7,C#,Asp.net,Windows,Wcf,Windows Phone 7,我创建了一个测试WP7应用程序,它使用一个WCF来获取一些样本数据 我添加了服务作为服务引用,并在其中生成了类。在应用程序中,我调用该服务: var service = new TestService.TestServiceClient(); service.GetDataCompleted += new EventHandler<TestService.GetDataCompletedEventArgs>(service_GetDataComplet

我创建了一个测试WP7应用程序,它使用一个WCF来获取一些样本数据
我添加了服务作为服务引用,并在其中生成了类。在应用程序中,我调用该服务:

var service = new TestService.TestServiceClient();
                service.GetDataCompleted += new EventHandler<TestService.GetDataCompletedEventArgs>(service_GetDataCompleted);
                service.GetDataAsync(new TestService.GetDataRequest());
var service=newtestservice.TestServiceClient();
service.GetDataCompleted+=新事件处理程序(service\u GetDataCompleted);
GetDataAsync(新的TestService.GetDataRequest());
在服务调用的回调中,我得到以下异常:

没有端点在侦听 这可以接受这个信息。这是 通常由不正确的地址引起 或SOAP操作。如果需要,请参阅InnerException 出席,了解更多详情

内部的例外情况是:

远程服务器返回了一个错误: 没有找到

调试时,cassini dev服务器启动。我可以毫无问题地从internet explorer访问svc,查看wsdl等

Visual Studio生成的配置文件:

<?xml version="1.0" encoding="utf-8"?>
<configurationSnapshot xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="urn:schemas-microsoft-com:xml-wcfconfigurationsnapshot">
  <behaviors />
  <bindings>
    <binding digest="System.ServiceModel.Configuration.BasicHttpBindingElement, System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089:&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-16&quot;?&gt;&lt;Data maxBufferSize=&quot;2147483647&quot; name=&quot;BasicHttpBinding_ITestService&quot;&gt;&lt;security mode=&quot;None&quot; /&gt;&lt;/Data&gt;" bindingType="basicHttpBinding" name="BasicHttpBinding_ITestService" />
  </bindings>
  <endpoints>
    <endpoint normalizedDigest="&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-16&quot;?&gt;&lt;Data address=&quot;http://localhost:8219/TestService.svc&quot; binding=&quot;basicHttpBinding&quot; bindingConfiguration=&quot;BasicHttpBinding_ITestService&quot; contract=&quot;TestService.ITestService&quot; name=&quot;BasicHttpBinding_ITestService&quot; /&gt;" digest="&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-16&quot;?&gt;&lt;Data address=&quot;http://localhost:8219/TestService.svc&quot; binding=&quot;basicHttpBinding&quot; bindingConfiguration=&quot;BasicHttpBinding_ITestService&quot; contract=&quot;TestService.ITestService&quot; name=&quot;BasicHttpBinding_ITestService&quot; /&gt;" contractName="TestService.ITestService" name="BasicHttpBinding_ITestService" />
  </endpoints>
</configurationSnapshot>


有什么想法吗???

您是否尝试过在实际运行的手机/模拟器上从IE访问svc URI

如果无法执行此操作,请检查手机上的代理设置。
如果是真正的手机,则只有通过USB连接到电脑时,此功能才起作用


我看到过这样的问题:即使新代码需要部署和运行/调试,emulator(出于未知原因)也无法进行网络连接。重新启动仿真器解决了这个问题。

好吧,这是您损失大量时间的情况之一,因为错误消息指出您离解决方案不远。


要解决这个问题,需要结合使用和重新生成服务引用。我知道这不是一个好答案,但这就是实际发生的情况

请在帖子中包含您的配置。可能未正确配置以使用该实际端点。这也是同样的解决方案吗?如果您发现并将其添加到您的客户项目中,这是相同的解决方案。我发现了您使用的绑定类型?您可以在配置中看到。这是由visual studiohey自动创建的!抱歉耽搁了。我使用的是windows phone模拟器,不是真正的手机。我刚刚尝试将url粘贴到emulator的浏览器中,它可以毫无问题地访问它。还有其他想法吗??(我也无法通过重新启动模拟器来解决问题)您是否尝试过使用WebClient.DownloadStringAsync()从应用程序中向URI发出请求,以查看这是网络问题还是您配置服务的方式。从应用程序中,指定的函数正正确返回服务html