2011-10-18 25 views
0

當我behaviorConfiguration添加我得到的從wcftester 以下遠程服務器返回錯誤:(415)不支持的媒體Type.HTTP得到錯誤加入behaviorConfiguration原因(415)不支持的媒體Type.HTTP得到錯誤

服務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> 

錯誤:

Cannot obtain Metadata from http://localhost:2622/MyRemoteHostService.svc If this is a Windows (R) Communication Foundation service to which you have access, please check that you have enabled metadata publishing at the specified address

The remote server returned an error: (415) Unsupported Media Type.HTTP GET Error URI: http://localhost:2622/MyRemoteHostService.svc The HTML document does not contain Web service discovery information.

回答

1

我得到了415個錯誤消息,花了我一天多的時間才找到原因,結果發現我們的web服務器上的web.config與dev不同,它指定了不同的綁定,這意味着綁定的不同客戶端(SL)和服務器上的wcf服務似乎會導致415消息(有道理)。你上面的綁定看起來是正確的,可能值得重新檢查。您是否嘗試添加行爲配置後更新服務引用,有時可以使用。不幸的是,HTTP錯誤代碼在有些時候可能會非常具有誤導性......

+0

解決我們的問題的方法是將名稱空間添加到正確的服務名稱和端點合同 – rob

相關問題