简体   繁体   English

WCF服务和Windows Phone应用程序在开发时

[英]WCF Service and Windows Phone app while developing

I've created a test WP7 app, which consumes a WCF to get some sample data 我创建了一个测试WP7应用程序,该应用程序使用WCF来获取一些示例数据
I added the service as a service reference, and the classes where generated. 我将服务添加为服务引用,并在其中生成了类。 In the app, I call the service : 在应用程序中,我称该服务为:

var service = new TestService.TestServiceClient();
                service.GetDataCompleted += new EventHandler<TestService.GetDataCompletedEventArgs>(service_GetDataCompleted);
                service.GetDataAsync(new TestService.GetDataRequest());

in the callback from the service call, i get the following exception : 在服务调用的回调中,出现以下异常:

There was no endpoint listening at http://localhost:8219/TestService.svc that could accept the message. http:// localhost:8219 / TestService.svc上没有侦听终结点的端点可以接受该消息。 This is often caused by an incorrect address or SOAP action. 这通常是由不正确的地址或SOAP操作引起的。 See InnerException, if present, for more details. 有关更多详细信息,请参见InnerException(如果存在)。

The inner exception says : 内部异常说:

The remote server returned an error: NotFound. 远程服务器返回错误:NotFound。

When debugging, the cassini dev server starts up. 调试时,cassini开发服务器将启动。 I can access the svc from internet explorer with no problem, see the wsdl, etc 我可以从Internet Explorer正常访问svc,请参阅wsdl等

Generated config file by Visual Studio : 由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>

Any ideas?? 有任何想法吗??

Have you tried accessing the svc URI from IE on the actual phone/emulator that you are running on? 您是否尝试过在实际运行的电话/模拟器上从IE访问svc URI?

If unable to do this, check the proxy settings on the phone. 如果无法执行此操作,请检查电话上的代理设置。
If an actual phone, this will only work if connected to the PC via USB. 如果是真正的电话,则仅在通过USB连接到PC时才有效。

I have seen issues where the emulator (for some unknown reason) stopped being able to make network connections even though new code cold be deployed and run/debugged. 我已经看到了一些问题,即使部署了新的代码并运行/调试了该模拟器(出于某种未知的原因),该模拟器仍然无法建立网络连接。 Restarting the emulator solved this. 重新启动模拟器解决了这个问题。

Well, this is one of the times when you lose a lot of time, because the error message points you to nowhere near the solution. 好吧,这是您浪费大量时间的情况之一,因为错误消息使您无法找到解决方案。

To fix this problem, it was a combination of this and regenerating the service reference. 要解决这个问题,它是组合这个再生业务的参考。 I know it's not a good answer, but that's what was actually happening 我知道这不是一个很好的答案,但这就是实际发生的情况

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM