2013-07-14 70 views
0

我正在努力解決如何在sharepoint 2010中使用城堡windsor託管wcf服務。通過使用http://msdn.microsoft.com/en-us/library/ff521586(v=office.14).aspx的服務工廠之一,我可以無任何問題地託管我自己的標準自定義Web服務。 用castle windsor設置一個普通的wcf服務需要修改global.asax,但是,因爲這不建議用於SharePoint,所以我創建了一個HttpModule來設置容器,並且我更新了web配置以通過創建一個特性來使用它reciever。 我的問題是下一步要去哪裏。我爲我的服務使用MultipleBaseAddressBasicHttpBindingServiceHostFactory,因爲它根據IIS配置動態配置服務的所有端點,但爲了使用castle windsor,它看起來像需要更改爲使用提供的Castle.Facilities.WcfIntegration.WindsorServiceHostFactory 。我試過只是切換看看會發生什麼,但似乎並不奏效。我收到以下錯誤SharePoint 2010託管wcf和城堡windsor

Error: Cannot obtain Metadata from <svc url> If this is a Windows (R) Communication Foundation service to which you have access, please check that you have enabled metadata publishing at the specified address. For help enabling metadata publishing, please refer to the MSDN documentation at http://go.microsoft.com/fwlink/?LinkId=65455.WS-Metadata Exchange Error URI: <svcurl> Metadata contains a reference that cannot be resolved: '<svcurl>'. The requested service, '<svcurl>' could not be activated. See the server's diagnostic trace logs for more information.HTTP GET Error URI: <svcurl> There was an error downloading '<svcurl>'. The request failed with HTTP status 404: Not Found. 

我想這是因爲我還沒有配置端點的服務,但我已經在網上看到了幾個例子似乎沒有或者根本。

有沒有人設法讓城堡windsor和sharepoint wcf工作 - 最好是動態配置,如果可能的話?

回答

0

您收到的錯誤消息是該服務的元數據未發佈。要做到這一點,你需要兩件事情:

爲您服務MEX端點:

<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" /> 

和服務元數據服務行爲打開:

<serviceMetadata httpGetEnabled="True" /> 
+0

好的,但是我應該如何定義配置服務?目前,我所有的sharepoint wcf服務都使用基於MultipleBaseAddressBasicHttpBindingServiceHostFactory的動態配置,並且已將BasicHttpBindingServiceMetadataExchangeEndpoint屬性添加到服務類以啓用mex端點。 – mcricker