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:<?xml version="1.0" encoding="utf-16"?><Data maxBufferSize="2147483647" name="BasicHttpBinding_ITestService"><security mode="None" /></Data>" bindingType="basicHttpBinding" name="BasicHttpBinding_ITestService" />
</bindings>
<endpoints>
<endpoint normalizedDigest="<?xml version="1.0" encoding="utf-16"?><Data address="http://localhost:8219/TestService.svc" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_ITestService" contract="TestService.ITestService" name="BasicHttpBinding_ITestService" />" digest="<?xml version="1.0" encoding="utf-16"?><Data address="http://localhost:8219/TestService.svc" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_ITestService" contract="TestService.ITestServi开发者_如何学Pythonce" name="BasicHttpBinding_ITestService" />" 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
精彩评论