0

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エンドポイントに設定されたこのプロパティに関連していますか?

4

1 に答える 1

1

私の間違い。REST応答メッセージにAutomatedFormatSelectionContentTypePropertyNameプロパティが含まれていることを確認していましたが、SOAP呼び出しではそれが含まれておらず、エラーが発生します。

だから私はこれを変更します

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

            }

これに

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

            }
于 2011-10-14T12:53:40.437 に答える