2011-01-20 62 views
0

我有一個WCF服務託管在Azure的卷軸中。WCF在Azure中無法訪問

當我在開發結構中測試它時,它可以從我的網頁(其他網絡角色)正常工作。

但是,當我將它部署到雲中時,它似乎並未運行,儘管webrole已準備就緒。

當我使用Fiddler做我的WCF服務的公共方法中的一種東西,我得到:

[提琴手]連接到 xxxxxxxxxxxxxx.cloudapp.net失敗。 異常文本:連接嘗試 失敗,因爲連接的方沒有 一段 時間後沒有正確響應或已建立的連接失敗 ,因爲連接的主機沒有 響應yyyyyyyyyyyyyy

這是服務配置:

<?xml version="1.0" encoding="utf-8"?> 
<ServiceDefinition name="GovGuard" xmlns="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceDefinition"> 
    <WebRole name="GovGuard.Services"> 
    <Sites> 
     <Site name="Web"> 
     <Bindings> 
      <Binding name="GuardServiceEndpointBinding" endpointName="GuardServiceEndpoint" /> 
     </Bindings> 
     </Site> 
    </Sites> 
    <ConfigurationSettings> 
     <Setting name="DevelopmentConnectionString" /> 
     <Setting name="GovGuardStorageConnectionString" /> 
    </ConfigurationSettings> 
    <Endpoints> 
     <InputEndpoint name="GuardServiceEndpoint" protocol="http" port="81" /> 
    </Endpoints> 
    <Imports> 
     <Import moduleName="Diagnostics" /> 
    </Imports> 
    <LocalResources> 
     <LocalStorage name="MyCompany.GovGuard.Services.svclog" sizeInMB="1000" cleanOnRoleRecycle="false" /> 
    </LocalResources> 
    </WebRole> 
    <WebRole name="GovGuard.Web"> 
    <Sites> 
     <Site name="Web"> 
     <Bindings> 
      <Binding name="GuardWebEndpointBinding" endpointName="GuardWebEndpoint" /> 
     </Bindings> 
     </Site> 
    </Sites> 
    <ConfigurationSettings> 
     <Setting name="GuardServiceUrl" /> 
     <Setting name="DevelopmentConnectionString" /> 
     <Setting name="GovGuardStorageConnectionString" /> 
    </ConfigurationSettings> 
    <Endpoints> 
     <InputEndpoint name="GuardWebEndpoint" protocol="http" port="80" /> 
    </Endpoints> 
    <Imports> 
     <Import moduleName="Diagnostics" /> 
    </Imports> 
    <LocalResources> 
     <LocalStorage name="MyCompany.GovGuard.Web.svclog" cleanOnRoleRecycle="false" sizeInMB="1000" /> 
    </LocalResources> 
    </WebRole> 
</ServiceDefinition> 

(編輯) 在我的問題的調查,可能是這樣的:我用的是Microsoft.SqlServer.Types裝配在文件基準WCF項目。我使用copy-local = true將程序集複製到bin文件夾,並將其打包在.csx文件中。但是...... Microsoft.SqlServer.Types還需要SqlServerSpatial.dll庫(不是程序集)。我創建了一個postbuild腳本來將該dll複製到bin中,但是我沒有成功......

也許有人可以幫助我如何將.dll文件(不是程序集)打包到.csx文件中。 ..

(編輯) 這裏找到它:http://msdn.microsoft.com/en-us/gg271395

+0

您可能需要共享一些代碼......一個常見的錯誤是將端口設置爲80以外的值。可能要檢查ServiceDefinition.csdef。 – smarx 2011-01-20 19:24:50

回答

1

終於有效的解決方案:我在32位Win7機器上開發,並將SqlServerSpatial.dll從我的機器複製到WCF項目(複製到輸出目錄和BuildAction內容)。這在雲中造成了一個奇怪的錯誤信息,因爲那個庫是32位的!我用64位版本更新了這個庫,現在在雲中部署完畢後,一切正常!

1

WCF沒有發揮很好,如果你正在嘗試做一個自我託管服務。

由於HTTP.sys註冊發生的方式,它會在本地計算機名稱上執行此操作,並且不允許您執行接受負載平衡名稱的通配符註冊。您擁有的選項是使用內部端點,並嘗試從您的Web主機連接輔助角色的IP。

我最終做的只是將我的WCF服務轉換爲MVC端點,並將我的工作者角色轉換爲Web應用程序。這不是最優雅的,但它的工作。

+0

嗨亞倫。我的解決方案可行WCF不應該成爲Azure中的問題,但要小心使用使用本地庫的CLR庫......在我的情況下,整個WCF服務沒有運行,因爲我沒有將本地庫作爲Azure的一部分包! – 2011-01-24 14:48:18