簡體   English   中英

Webservice返回錯誤的內容類型響應頭

[英]Webservice returns wrong content-type response header

我試圖在asp.net c#應用程序中使用第三方Web服務(基於php),並且服務配置失敗。已經嘗試添加服務/ Web引用 - 所有相同的錯誤:

響應消息的內容類型text / html與綁定的內容類型(text / xml; charset = utf-8)不匹配。 如果使用自定義編碼器,請確保正確實現IsContentTypeSupported方法。 響應的前402個字節是:'<?xml version =“1.0”encoding =“utf-8”?> <soap:Envelope xmlns:soap =“http://schemas.xmlsoap.org/soap/envelope/ “xmlns:xsi =”http://www.w3.org/2001/XMLSchema-instance“xmlns:xsd =”http://www.w3.org/2001/XMLSchema“> <soap:Body>; <。 ..

[手動編輯響應以正確顯示> <字符,否則完全有效]

對我而言,它似乎是一個完全有效的響應,我試着看看fiddler在響應頭中寫的內容 - Content-Type:text / html,這可能是問題的根源 - webservice看錯了內容類型(text / html而不是text / xml),但如何配置我的客戶端忽略/覆蓋收到的內容類型? 谷歌搜索沒有給我什么,所以請,如果有人可以幫助 - 問題是什么? Binding \\ endpoint配置是默認的basicHttpBinding / endpoint,它是由VS2010在使用Add Service Reference選項時生成的,沒有任何更改。 提前致謝。

[的app.config]

<?xml version="1.0"?>
<configuration>
<configSections>
<sectionGroup  name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=4.0.0.0,      Culture=neutral, PublicKeyToken=b77a5c561934e089">
  <section name="Collection.ServicePlayground.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false"/>
</sectionGroup>
</configSections>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="SmsServiceSoap1" closeTimeout="00:01:00" openTimeout="00:01:00"
    receiveTimeout="00:10:00" sendTimeout="00:01:00" allowCookies="false"
    bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
    maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
    messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
    useDefaultWebProxy="true">
    <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
    maxBytesPerRead="4096" maxNameTableCharCount="16384" />
    <security mode="None">
    transport clientCredentialType="None" proxyCredentialType="None"
    realm="" />
    <message clientCredentialType="UserName" algorithmSuite="Default" />
    </security>
    </binding>
  </basicHttpBinding>
</bindings>
<client>
  <endpoint address="http://ws1.streamsms.ru/SmsService.php" binding="basicHttpBinding"
    bindingConfiguration="SmsServiceSoap1" contract="SmsService.SmsServiceSoap"
    name="SmsServiceSoap2" />
</client>
</system.serviceModel>
<applicationSettings>
<Collection.ServicePlayground.Properties.Settings>
  <setting name="Collection_ServicePlayground_WSStreamProvider_SmsService"   serializeAs="String">
    <value>http://ws1.streamsms.ru/SmsService.php</value>
  </setting>
 </Collection.ServicePlayground.Properties.Settings>
 </applicationSettings>
 </configuration>

我不確定,但你認為你遇到了這里顯示的內容: http//cushen.wordpress.com/2009/04/08/web-service-content-type-error-using-visual-studio-2008 /

看起來非常相似..您應該使用添加Web引用與添加服務引用(因為后者適用於WCF樣式服務?)

也許.. :)

也許是矯枉過正,但您可以嘗試使用自定義編碼器進行綁定。 默認為text / xml。

http://msdn.microsoft.com/en-us/library/ms751486.aspx

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM