开发者

WCF Service and Windows Phone app while developing

开发者 https://www.devze.com 2023-03-05 09:05 出处:网络
I\'ve created a test WP7 app, which consumes a WCF to get some sample data I added the service as a service reference, and the classes where generated. In the app, I call the service :

I've created a test WP7 app, which consumes a WCF to get some sample data

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. This is often caused by an incorrect address or SOAP action. See InnerException, if present, for more details.

The inner exception says :

The remote server returned an error: NotFound.

When debugging, the cassini dev server starts up. I can access the svc from internet explorer with no problem, see the wsdl, etc

Generated config file by 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.ITestServi开发者_如何学Pythonce&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?

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.

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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号