2011-10-06 87 views
0

我得到這個錯誤試圖打電話給我在WcfTestClient名稱爲「AutomatedFormatSelectionContentTypePropertyName」的屬性不存在

服務

我的配置:

<services> 
     <service behaviorConfiguration="MetadataBehavior" name="ServiceModel.Service"> 
     <endpoint address="soap" binding="basicHttpBinding" name="Soap" 
      contract="ServiceModel.IService" /> 
     <endpoint address="rest" behaviorConfiguration="jsonBehavior" 
      binding="webHttpBinding" bindingConfiguration="webHttpBindingSettings" 
      name="Json" contract="ServiceModel.IService" /> 
     <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" /> 
     <host> 
      <baseAddresses> 
      <add baseAddress="http://dev.add.com/Service.svc/" /> 
      </baseAddresses> 
     </host> 
     </service> 
    </services> 
    <behaviors> 
     <serviceBehaviors> 
     <behavior name="MetadataBehavior"> 
      <serviceDebug includeExceptionDetailInFaults="true" /> 
      <serviceMetadata httpGetEnabled="true" /> 
     </behavior> 
     </serviceBehaviors> 
     <endpointBehaviors> 
     <behavior name="jsonBehavior"> 
      <webHttp automaticFormatSelectionEnabled="true" helpEnabled="true"/> 
     </behavior> 
     </endpointBehaviors> 
    </behaviors> 

爲什麼我得到這個錯誤,它與這個屬性連接爲json端點設置?

+0

沒有在這個問題診斷您的問題足夠的信息。然而,這看起來非常像你從另一個問題的配置(http://stackoverflow.com/questions/7675739/the-message-with-action-cannot-be-processed-at-the-receiver-due-to -合同)。 從這個問題可以清楚地看到,您的實施細節污染了您的合同,並且正在嘗試手動填充消息請求。請提供您正在進行的調用的詳細信息,並提供異常的堆棧跟蹤。 –

回答

0

我的錯誤。我正在檢查REST響應消息是否包含AutomatedFormatSelectionContentTypePropertyName屬性,但在SOAP調用中它不包含它並引發錯誤。

所以我改變了

if (OperationContext.Current.OutgoingMessageProperties.ContainsKey("AutomatedFormatSelectionContentTypePropertyName")) 
      { 

      } 

這個

if (OperationContext.Current.OutgoingMessageProperties != null && OperationContext.Current.OutgoingMessageProperties.ContainsKey("AutomatedFormatSelectionContentTypePropertyName")) 
      { 

      } 
相關問題