2011-06-21 68 views
4

我想使用免費的Microsoft Visual Web Developer 2010 Express在WCF中開始事務。它給了我創建一個「WCF服務應用程序」的選項,但它似乎沒有給我很多選項來託管它或配置不同的綁定。如果我F5的項目,我得到的錯誤:來自Visual Studio 2010 Express的WCF中的TransactionFlow

At least one operation on the 'Service' contract is configured with the TransactionFlowAttribute attribute set to Mandatory but the channel's binding 'BasicHttpBinding' is not configured with a TransactionFlowBindingElement. The TransactionFlowAttribute attribute set to Mandatory cannot be used without a TransactionFlowBindingElement.

我嘗試添加在*/services/service/endpoint配置到web.config中,但它似乎只是被忽略。我也嘗試將默認啓動應用程序更改爲WcfSvcHost.exe,但此選項呈灰色。我開始懷疑Express版的一些失敗,但我樂觀地認爲,這只是我的一個愚蠢。是否有一個我需要學習的技巧,或者會在Visual Studio 2010的完整版本上冒出來,足以讓我跨越這個障礙到達下一個?

謝謝!

+0

,你能否告訴我們的服務合同,配置文件? –

+0

我正在使用「WCF服務應用程序」中的香草示例,只有我向服務合同中的某個操作添加了TransactionFlow屬性。 Web.config中沒有定義任何服務。我不知道反射魔法是怎麼回事,但即使我嘗試使用wsHttpBinding設置端點(注意錯誤消息始終是BasicHttpBinding),但我沒有運氣。 – Jono

回答

6

不知道您的配置和服務合同幾乎不可能做出有針對性的回答。如果您認爲您的配置被忽略,請確保在serviceendpoint/@contract中使用的名稱包含CLR名稱空間。

WCF 4使用很好的簡化配置,恕我直言,讓真正的配置更大的痛苦,然後它是以前。您可以通過添加給你的web配置切換默認值:

<protocolMapping> 
    <remove scheme="http" /> 
    <add scheme="http" binding="wsHttpBinding" bindingConfiguration="transactionFlowEnabled"/> 
</protocolMapping> 
<bindings> 
    <wsHttpBinding> 
    <binding name="transactionFlowEnabled" transactionFlow="true" /> 
    </wsHttpBinding> 
</bindings> 

這是應該使用定義爲默認,而不是basicHttpBinding約束力的解決辦法。

+0

你的答案都是現貨。謝謝! – Jono

1

感謝拉吉斯拉夫的建議下,我能夠通過添加以下條目到Web.config文件,以解決這個問題:

<services> 
    <service name="WcfService1.Service1"> 
    <endpoint 
     address="" 
     binding="wsHttpBinding" 
     contract="WcfService1.IService1" 
     /> 
    </service> 
</services>

和:

<bindings> 
    <wsHttpBinding> 
    <binding transactionFlow="true"/> 
    </wsHttpBinding> 
</bindings>
+0

你在服務器或客戶端的web.config中寫入了哪些內容? – Para

相關問題