【问题标题】:adding behaviorConfiguration causes (415) Unsupported Media Type.HTTP GET Error添加 behaviorConfiguration 导致 (415) Unsupported Media Type.HTTP GET 错误
【发布时间】:2011-10-18 13:04:53
【问题描述】:

当我添加 behaviorConfiguration 时,我从 wcftester 获得以下信息 远程服务器返回错误:(415) Unsupported Media Type.HTTP GET Error

服务 web.config

  <system.serviceModel>
    <services>
      <service  behaviorConfiguration="MaxConfig" name="MyRemoteHostService">
        <endpoint address="" binding="basicHttpBinding"
                  bindingConfiguration="BasicHttpBinding_MyRemoteHostService"
                  contract="My.Framework.Web.MyRemoteHostService" />

        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
      </service>
    </services>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="false"
      multipleSiteBindingsEnabled="true" />



    <bindings>
      <basicHttpBinding>
        <binding name="BasicHttpBinding_MyRemoteHostService"
            maxBufferPoolSize="2147483647"
            maxReceivedMessageSize="2147483647"
            maxBufferSize="2147483647">
          <readerQuotas
              maxArrayLength="2147483647"
              maxBytesPerRead="2147483647"
              maxDepth="2147483647"
              maxNameTableCharCount="2147483647"
              maxStringContentLength="2147483647" />
        </binding>
      </basicHttpBinding>
    </bindings>



    <behaviors>
      <serviceBehaviors>
        <behavior name="MaxConfig">
          <serviceMetadata httpGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="false" />
          <dataContractSerializer maxItemsInObjectGraph="2147483647" />
        </behavior>
      </serviceBehaviors>
    </behaviors>


  </system.serviceModel>

ServiceReferences.ClientConfig

  <system.serviceModel>
    <bindings>
      <basicHttpBinding>
        <binding name="BasicHttpBinding_MyRemoteHostService" maxBufferSize="2147483647"
          maxReceivedMessageSize="2147483647">
          <security mode="None" />
        </binding>
      </basicHttpBinding>
    </bindings>
    <client>
      <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
      <endpoint address="http://localhost:2622/MyRemoteHostService.svc"
        binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_MyRemoteHostService"
        contract="MyServiceReference.MyRemoteHostService" name="BasicHttpBinding_MyRemoteHostService" />
    </client>
  </system.serviceModel>

错误:

无法获取元数据 http://localhost:2622/MyRemoteHostService.svc 如果这是 Windows (R) 请访问您有权访问的通信基础服务 检查您是否已在指定位置启用元数据发布 地址

远程服务器返回错误:(415) Unsupported Media Type.HTTP 获取错误 URI:http://localhost:2622/MyRemoteHostService.svc HTML 文档不包含 Web 服务发现信息。

【问题讨论】:

    标签: silverlight wcf


    【解决方案1】:

    我收到一个415错误消息我花了一天多的时间才找到原因,原来我们服务器上的web.config与dev不同,它指定了不同的绑定,这意味着客户端之间的绑定不同( SL)和服务器上的 wcf 服务似乎会导致 415 消息(有点道理)。您上面的绑定看起来正确,可能值得重新检查。您是否尝试在添加行为配置后更新服务引用,有时它可以工作。不幸的是,HTTP 错误代码有时会非常具有误导性......

    【讨论】:

    • 对我们的修复是将命名空间添加到正确的服务名称和端点合同
    猜你喜欢
    • 1970-01-01
    • 2017-08-05
    • 2012-04-19
    • 2017-11-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-01-21
    • 2019-05-19
    相关资源
    最近更新 更多