1

Duplex Web サービスを機能させるのに問題があります。次のエラーが表示されます。

ServiceModel クライアント構成セクションで、コントラクト 'IService1' を参照する既定のエンドポイント要素が見つかりませんでした。これは、アプリケーションの構成ファイルが見つからなかったか、このコントラクトに一致するエンドポイント要素がクライアント要素に見つからなかったためである可能性があります。

これは、サービスにアクセスしようとしている単体テストによってスローされます。私は同様のSOの質問を見つけました:

デフォルトのエンドポイント要素が見つかりませんでした

WCF エラー - コントラクト 'UserService.UserService' を参照する既定のエンドポイント要素が見つかりませんでした

そして答えは「設定ファイルを他のプロジェクトにインクルードする」ということですが、これは具体的にどういう意味なのでしょうか?

  • サービスを DLL にコンパイルしてインクルードしますか?
  • 「system.serviceModel」またはそのサブセットに含まれるすべてをコピーしますか?
  • エンドポイントと関係がありますか?

編集:構成ファイル

Web.config

<?xml version="1.0"?>
<configuration>
  <system.web>
    <compilation debug="true" targetFramework="4.0" />
  </system.web>
      <system.serviceModel>
    <behaviors>
      <serviceBehaviors>
        <behavior name ="svcbh">
          <serviceMetadata httpGetEnabled="False"/>
          <serviceDebug includeExceptionDetailInFaults="False"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <!--<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />-->
    <services>
      <service name ="Test_Duplex.Service1" behaviorConfiguration ="svcbh" >
        <host>
          <baseAddresses>
            <add baseAddress = "http://localhost:3857/Service1.svc" />
          </baseAddresses>
        </host>
        <endpoint name ="duplexendpoint"
                  address =""
                  binding ="wsDualHttpBinding"
                  contract ="Test_Duplex.IService1"/>
        <endpoint name ="MetaDataTcpEndpoint"
                  address="mex"
                  binding="mexHttpBinding"
                  contract="IMetadataExchange"/>
      </service>
    </services>
  </system.serviceModel>
  <system.webServer>
    <modules runAllManagedModulesForAllRequests="true"/>
  </system.webServer>
</configuration>

output.config

<?xml version="1.0" encoding="utf-8"?>
<configuration>
    <system.serviceModel>
        <bindings>
            <wsDualHttpBinding>
                <binding name="duplexendpoint" closeTimeout="00:01:00"      openTimeout="00:01:00"
                    receiveTimeout="00:10:00" sendTimeout="00:01:00" bypassProxyOnLocal="false"
                    transactionFlow="false" hostNameComparisonMode="StrongWildcard"
                    maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
                    messageEncoding="Text" textEncoding="utf-8"   useDefaultWebProxy="true">
                    <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
                        maxBytesPerRead="4096" maxNameTableCharCount="16384" />
                    <reliableSession ordered="true" inactivityTimeout="00:10:00" />
                    <security mode="Message">
                        <message clientCredentialType="Windows" negotiateServiceCredential="true"
                            algorithmSuite="Default" />
                    </security>
                </binding>
            </wsDualHttpBinding>
        </bindings>
        <client>
             <endpoint address="http://localhost:3857/Service1.svc" binding="wsDualHttpBinding"
                bindingConfiguration="duplexendpoint" contract="Test_Duplex.IService1"
                name="duplexendpoint">
                <identity>
                    <userPrincipalName value="12680@altus.local" />
                </identity>
            </endpoint>
        </client>
    </system.serviceModel>
</configuration>
4

2 に答える 2

1

代わりにwsdl生成ファイル (Service1.svc、output.config) をサービス参照に切り替え、代わりにそこからクラス定義を取得しました。これを行っているチュートリアルも見ることができます。

上司がコマンド プロンプトで実行するように教えてくれたので、頭をすり抜けたに違いありません。

これにより、「エンドポイントが見つかりません」というエラーが修正されました。

于 2012-05-01T22:19:50.377 に答える
1

設定ファイルの問題です。構成ファイルを生成したときに、型の名前空間が完全に指定されていません。通常、必要なのは<Namespace>.IService1

于 2012-04-26T21:12:36.167 に答える