6

IIS に公開しようとしている WCF Web サービスがあります。wsdl は問題なく表示できますが、[サービス参照の追加] メニューから Visual Studio 2010 にサービスを追加できません。次のエラーが表示されます。

Metadata contains a reference that cannot be resolved: 'http://localhost:4567/Service.svc?wsdl'.
The WSDL document contains links that could not be resolved.
There was an error downloading 'http://localhost:4567/Service.svc?xsd=xsd0'.
The underlying connection was closed: An unexpected error occurred on a receive.
Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host.
An existing connection was forcibly closed by the remote host
Metadata contains a reference that cannot be resolved: 'http://localhost:4567/Service.svc'.
Content Type application/soap+xml; charset=utf-8 was not supported by service http://localhost:4567/Service.svc.  The client and service bindings may be mismatched.
The remote server returned an error: (415) Cannot process the message because the content type 'application/soap+xml; charset=utf-8' was not the expected type 'text/xml; charset=utf-8'..
If the service is defined in the current solution, try building the solution and adding the service reference again.

ローカルではうまく機能しますが、IIS に公開された場合は機能しません。

この問題の原因を知っている人はいますか? これが私のweb.configです。私はWCFを初めて使用するため、何かを見落としている可能性があります。

<?xml version="1.0"?>
<configuration>

  <system.web>
    <compilation debug="true" targetFramework="4.0" />
  </system.web>
  <system.serviceModel>
    <behaviors>
      <serviceBehaviors>
        <behavior>
          <!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
          <serviceMetadata httpGetEnabled="true"/>
          <!-- To receive exception details in faults for debugging purposes, set the value below to true.  Set to false before deployment to avoid disclosing exception information -->
          <serviceDebug includeExceptionDetailInFaults="true"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
  </system.serviceModel>
 <system.webServer>
    <modules runAllManagedModulesForAllRequests="true"/>
  </system.webServer>
  <connectionStrings>

  </connectionStrings>
</configuration>
4

8 に答える 8

11

ビルド時または実行時の WCF 構成エラーに関するより的を絞った情報を提供するために、Microsoft がより適切な診断機能を導入してくれることを心から願っています。

</rant>

私にとって、この途方もなく一般的なエラーの原因は次のとおりです。

<endpoint address="mexTcp" binding="mexTcpBinding" contract="IMetadataExchange"/>

これである必要があります:

<endpoint address="mex" binding="mexTcpBinding" contract="IMetadataExchange"/>

IDE で簡単に強調表示できたはずの Net.Tcp を有効にしようとして、2 時間もおならを言いました。2時間!!!

于 2016-10-13T20:29:35.287 に答える
3

これは、Google がこのエラーに対して表示する最初の投稿の 1 つであるため、私のソリューションに参加したいと思います。

正常に動作しているシステムでコードを変更しているときに同様のエラーが発生しましたが、開発システムで参照を更新できませんでした。参照はsilverlightプロジェクト内にあり、周囲のWebサイトに統合されたWCFに関連しています(標準構成だと思います)。

私のエラーメッセージが含まれています

「WCF メタデータには、解決できない参照が含まれています: 'いくつかの面白いパス'。応答メッセージのコンテンツ タイプ text/html; charset=utf-8 がバインディングのコンテンツ タイプ (application/soap+xml; charset) と一致しません。 =utf-8)」

私のウェブサイトは承認の役割を使用しています。これが問題/解決策の基になっています。サービス参照を更新するには、すべてのユーザーを許可する必要がありました。

<?xml version="1.0"?>
<configuration>
    <system.web>
        <!--<authorization>
            <allow users="*"/>            
        </authorization>-->
        <authorization>
            <deny users="?"/>
            <allow roles="role-1,role-2"/>
            <deny users="*"/>
        </authorization>
    </system.web>
</configuration>
于 2014-10-20T13:34:56.983 に答える
2

こちらのMSDN フォーラムで回答を確認してください

IMetadataExchangenet tcp プロトコルを定義するときは、エンドポイント コントラクトで定義されたコントラクトを使用していることを確認する必要があります。このためのサービス動作にも<serviceMetadata />タグを含める必要があります。私が理解したことから、VSでプロキシ/ディスカバーをホストおよび生成したい場合、これは構成の定型コードです。

<endpoint address="mex" binding="mexTcpBinding" contract="IMetadataExchange" />
于 2013-07-24T10:14:52.433 に答える