2011-05-13 109 views
1

我創建了一個測試WP7應用程序,它使用WCF來獲取一些示例數據
我添加了服務作爲服務引用以及生成的類。在應用中,我撥打服務:開發WCF服務和Windows Phone應用程序

var service = new TestService.TestServiceClient(); 
       service.GetDataCompleted += new EventHandler<TestService.GetDataCompletedEventArgs>(service_GetDataCompleted); 
       service.GetDataAsync(new TestService.GetDataRequest()); 
從服務調用回調

,我得到以下異常:

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 remote server returned an error: NotFound.

當調試時,cassini dev服務器啓動。我可以通過Visual Studio中沒有問題,訪問來自Internet Explorer中的SVC,看到WSDL等

生成的配置文件:

<?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> 

任何想法?

+0

請在您的文章中包含您的配置。可能配置不好以使用該實際端點。也是同樣的解決方案?如果你是發現並將其添加到客戶項目中的? – 2011-05-13 08:07:05

+0

這是相同的解決方案。我做了一個發現 – 2011-05-13 08:24:40

+0

你使用什麼類型的綁定? – 2011-05-13 08:26:35

回答

0

嗯,這是你失去了很多時間的時候,因爲錯誤信息指出你遠離解決方案。

要解決此問題,它是this的組合並重新生成服務引用。我知道這不是一個好的答案,但這就是實際發生的事情

0

您是否嘗試過從您正在運行的實際手機/模擬器上訪問來自IE瀏覽器的svc URI?

如果無法執行此操作,請檢查手機上的代理設置。
如果是實際的手機,只有通過USB連接到PC才能工作。

我看到了模擬器(出於某種未知原因)停止了能夠進行網絡連接的問題,即使部署了新代碼並運行/調試了新代碼。重新啓動模擬器解決了這個問題。

+0

創建的自動的嗨!抱歉耽擱了。我使用Windows Phone模擬器,而不是真正的手機。我剛剛嘗試將網址粘貼到模擬器的瀏覽器中,並且可以毫無問題地訪問它。任何其他的想法? (我無法通過重新啓動模擬器來解決此問題) – 2011-05-18 15:07:49

+0

您是否嘗試過使用WebClient.DownloadStringAsync()從應用程序中向URI發出請求,以查看它是網絡問題還是您配置服務。 – 2011-05-18 15:38:15

+0

從應用程序內,指定的功能正在返回正確的服務的HTML – 2011-05-19 19:37:07

相關問題