2011-10-06 44 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")) 
      { 

      } 
相关问题