2

私はWCFの初心者です。IIS に WCF を展開し、サービスを利用する手順を検討しています。IIS に Web サイトを展開するのと同じ手順に従い、デフォルトのドキュメントを Service1.svc に設定しました。

この wcf サービスを使用しようとすると、次のエラーが表示されます。

Metadata contains a reference that cannot be resolved: 'http://manish-pc:8000/Service1.svc?wsdl'.
The WSDL document contains links that could not be resolved.
There was an error downloading 'http://manish-pc:8000/Service1.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:8000/Service1.svc'.
Content Type application/soap+xml; charset=utf-8 was not supported by service http://localhost:8000/Service1.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.

以下は、Web.Configファイルのサービスの詳細です

<system.serviceModel>
    <services>
      <service behaviorConfiguration="DemoWCF.Service1Behavior" name="DemoWCF.Service1">
        <host>
          <baseAddresses>
            <add baseAddress="http://localhost:8000/Service1.svc"/>
          </baseAddresses>
        </host>
        <endpoint address="http://localhost:8000/Service1.svc"
                  binding="basicHttpBinding"
                  contract="DemoWCF.IService1"
                  bindingConfiguration="basicBinding">
          <identity>
            <dns value="localhost"/>
          </identity>
        </endpoint> 
        <endpoint address="mex" 
                  binding="mexHttpBinding" 
                  contract="IMetadataExchange" />
      </service>
    </services>

    <bindings>
      <basicHttpBinding>
        <binding name="basicBinding" textEncoding="utf-8"></binding>
      </basicHttpBinding>
    </bindings>

    <behaviors>
      <serviceBehaviors>
        <behavior name="DemoWCF.Service1Behavior">
          <serviceMetadata httpGetEnabled="True" />
          <serviceDebug includeExceptionDetailInFaults="false" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>

私が欠けているところと、どのような手順を踏むべきかを教えてください。ありがとう。

4

1 に答える 1

5

グーグルで検索して動画を見た後。最後に私は解決策を得ました。

このエラーは、私が気にしていなかった IIS 構成が原因で発生します。

  1. IIS マネージャー コンソールを開きます。
  2. 別のアプリケーション プールを作成します。
    a)。.NET Framework のバージョンを 4.0 に設定します
    b)。マネージド パイプライン モード: クラシック
  3. アプリケーション プール ID を「LocalSystem」に設定します。
  4. 仮想ディレクトリの作成など、IIS に Web アプリケーションを展開する場合と同じ手順に従います。
  5. 作成したアプリケーション プールに仮想ディレクトリ セットを作成します。

クライアント アプリケーションで WCF サービスを使用します。

ビデオを見るにはここをクリック

これについての詳細を見つけた場合は、この質問/回答スレッドを更新してください。
ありがとう :)

于 2013-02-07T12:00:50.657 に答える