Свойство с именем 'AutomatedFormatSelectionContentTypePropertyName' отсутствует - PullRequest
0 голосов
/ 06 октября 2011

Я получаю эту ошибку, пытаясь вызвать мой сервис в WcfTestClient

Моя конфигурация:

 <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?

1 Ответ

0 голосов
/ 14 октября 2011

Моя ошибка.Я проверял, что ответное сообщение REST содержит свойство AutomatedFormatSelectionContentTypePropertyName, но при вызове SOAP оно не содержит его и выдает ошибку.

поэтому я изменяю это

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

            }

на это

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

            }
...