2011-01-07 37 views
1

我試圖創建由ASP.NET主辦的wcf服務(我前段時間做過,但現在我不能...)如何在enableWebScript設置時添加元數據支持?

在這一步我想添加元數據支持。一旦我添加了以下端點配置:

<endpoint address="mex" behaviorConfiguration="McActivationApp.EnrollmentServiceAspNetAjaxBehavior" 
binding="mexHttpBinding" contract="IMetadataExchange" /> 

我有以下錯誤:

The endpoint at 'http://MyPcName/MCActivation/EnrollmentService.svc/mex' does not have a Binding with the None MessageVersion. 'System.ServiceModel.Description.WebScriptEnablingBehavior' is only intended for use with WebHttpBinding or similar bindings.

我試圖改變「IMetadataExchange接口」合同'。這會導致另一個錯誤:

The endpoint at 'http://MyPcName/MCActivation/EnrollmentService.svc/mex' does not have a Binding with the None MessageVersion. 'System.ServiceModel.Description.WebScriptEnablingBehavior' is only intended for use with WebHttpBinding or similar bindings.

請指教,我該如何正確添加對元數據的支持?


這裏是完整的'system.serviceModel'部分。

<system.serviceModel> 
<behaviors> 
    <endpointBehaviors> 
    <behavior name="McActivationApp.EnrollmentServiceAspNetAjaxBehavior"> 
    <enableWebScript /> 
    </behavior> 
    </endpointBehaviors> 
    <serviceBehaviors> 
     <behavior name="McActivationApp.EnrollmentServiceAspNetAjaxBehavior"> 
     <serviceMetadata httpGetEnabled="True"/> 
     </behavior> 
    </serviceBehaviors> 
    </behaviors> 
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" /> 
    <services> 
    <service behaviorConfiguration="McActivationApp.EnrollmentServiceAspNetAjaxBehavior" 
    name="McActivationApp.EnrollmentService"> 
    <endpoint address="" behaviorConfiguration="McActivationApp.EnrollmentServiceAspNetAjaxBehavior" 
    binding="webHttpBinding" contract="McActivationApp.EnrollmentService" /> 
    <endpoint address="mex" behaviorConfiguration="McActivationApp.EnrollmentServiceAspNetAjaxBehavior" 
    binding="mexHttpBinding" contract="McActivationApp.EnrollmentService" /> 
    </service> 
    </services> 
</system.serviceModel> 
</configuration> 

回答

1

我做了什麼來解決問題:創建新的WcfServiceLibrary項目並分析它的應用配置。

此基礎上,我做了以下內容:

<system.serviceModel> 
<behaviors> 
    <serviceBehaviors> 
    <behavior name="McActivationApp.EnrollmentServicBehavior"> 
     <serviceMetadata httpGetEnabled="True"/> 
     <serviceDebug includeExceptionDetailInFaults="False" /> 
    </behavior> 
    </serviceBehaviors> 
</behaviors> 
<services> 
    <service name="McActivationApp.EnrollmentService" behaviorConfiguration="McActivationApp.EnrollmentServicBehavior"> 
    <endpoint address="" binding="webHttpBinding" contract="McActivationApp.EnrollmentService"/> 
    <endpoint address="mex" binding="mexHttpBinding" contract="McActivationApp.EnrollmentService" /> 
    </service> 
</services> 
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" /> 
</system.serviceModel> 

的主要區別是,我已經從移動服務端點配置行爲規範到服務本身。

而且我已經刪除了「端點」的行爲和所使用的唯一的「服務」端點

2

如果從服務標籤中刪除behaviorConfiguration="McActivationApp.EnrollmentServiceAspNetAjaxBehavior"會發生什麼情況。我也會嘗試賦予行爲獨特的名稱,這可能會導致一些混淆。

+0

+1右上 - MEX終結點**不能**有任何WebScript行爲之類的東西就可以啓用! – 2011-01-08 08:01:22

相關問題