2013-10-14 182 views
0

我有一些關於在完成編碼之後設置和運行WCF服務的問題。測試WCF服務

我創建了我的服務。我可以在VS中右鍵單擊它並選擇在瀏覽器中運行它,然後出現。

現在我想通過創建一個新的C#項目並向我的服務添加服務引用來測試綁定服務(.svc)。

當我嘗試添加服務引用時,找不到它(例如http://localhost:55129/Cars.svc)。

那麼,我需要運行我的服務項目才能添加它嗎?

我需要在IIS中設置它嗎?還是人們主要從VS內部運行它,運行WCF項目本身?

這裏是嘗試添加服務端點時,我得到的錯誤:如果您使用的是開發Web服務

There was an error downloading http://localhost:55129/Cars.svc/_vti_bin/ListData.svc/$metadata .
The request failed with HTTP status 400: Bad Request.
Metadata contains a reference that cannot be resolved: http://localhost:55129/Cars.svc .
Content Type application/soap+xml; charset=utf-8 was not supported by service http://localhost:55129/Events.svc . The client and service bindings may be mismatched.
The remote server returned an error: (415) Cannot process the message because the content type 'application/soap+xml; charset=utf-8' was not the expected type 'text/xml; charset=utf-8'..
If the service is defined in the current solution, try building the solution and adding the service reference again.

回答

1

,它必須運行,爲您生成客戶端代理。

在IIS中託管更方便,因爲它始終運行,即使您沒有打開解決方案。

+0

這就是我的想法。另外我想我需要獲得Svcutil.exe並創建一個客戶端對象,以便我可以從本質上測試WSDL ......對吧? – PositiveGuy

+0

這就是我所做的,但也許還有其他方法。 – Szymon

+0

似乎並不像我甚至需要Svcutil.exe,我想這只是爲客戶端創建一個配置文件。在引用另一個C#項目中的服務之後,生成的wsdl似乎爲您創建了一個服務客戶端,用於您引用的任何服務 – PositiveGuy