0

asp.net c# アプリケーションでサードパーティの Web サービス (php ベース) を使用しようとしていますが、サービス構成で失敗しました。既にサービス/Web 参照を追加しようとしました - すべて同じエラー:

応答メッセージのコンテンツ タイプ text/html がバインディングのコンテンツ タイプ (text/xml; charset=utf-8) と一致しません。カスタム エンコーダーを使用する場合は、IsContentTypeSupported メソッドが適切に実装されていることを確認してください。応答の最初の 402 バイトは次のとおりです。 " xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Body>;<. ..

[応答は手動で編集され、> < 文字が正しく表示されます。それ以外の場合は完全に有効です]

私には、それは完全に有効な応答のように思えます。フィドラーが応答ヘッダーに書き込む内容を確認しようとしました - Content-Type: text/html、これがおそらく問題の原因です - Web サービスが間違った content-type を送信しました (代わりに text/html) text/xml の) ですが、受信した content-type を無視/上書きするようにクライアントを構成するにはどうすればよいですか? グーグルは私に何も得られないので、誰かが助けてくれるならお願いします-問題はどこですか? Binding\endpoint 構成は、[サービス参照の追加] オプションを使用したときに VS2010 によって生成されるデフォルトの basicHttpBinding/endpoint であり、何も変更されていません。前もって感謝します。

[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>
4

2 に答える 2

1

よくわかりませんが、ここに示されている内容に遭遇していると思いますか: http://cushen.wordpress.com/2009/04/08/web-service-content-type-error-using-visual-studio-2008 /

かなり似ているようです.. Web 参照の追加とサービス参照の追加を使用する必要があります (後者は WCF スタイルのサービスのためなのでしょうか?)

多分.. :)

于 2012-06-21T11:09:31.493 に答える
1

おそらくやり過ぎかもしれませんが、バインディング用のカスタムエンコーダーを試すことができます。デフォルトは text/xml です。

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

于 2012-06-21T21:03:09.237 に答える