0

こんにちは、WCF サービス ライブラリ プロジェクトがあり、テスト用にホストする WPF アプリを作成しましたが、問題なく動作しますが、IIS で運用用にホストする Web アプリも作成し、IIs に接続しようとすると、私は決してできません。

私は net.tcp バインドを使用しており、IIS にアクセスして net.tcp バインドを Web アプリと Web サイトに追加しました。

基本的に、これは一方向としてマークされたメソッドを持つ二重サービスです。クライアントでメソッドを呼び出すと、コールバックは呼び出されず、アプリケーションを閉じる前に数分間待っているだけです。サービスを自分でホストすると、コールバックですぐに応答が返されます。

また、localhost:808 と localhost だけを使用してみました。svcutil を使用して構成を生成すると、アドレスからポートが除外されます。認識しているエラーは発生しませんが、IIS からスローされたエラーが発生したかどうかを確認する方法が正直にわかりません。

また、 にアクセスするhttp://localhost:9595/EcuWebService/Service.svcと、svcutil を使用してクライアント プロキシを生成するように指示するページが表示されます。

Jocke が以下で提案したように、デバッガーをアタッチしましたが、次のエラーを受け取りました: サービス '/EcuWebService/service' が存在しません。

また、ここに私のsvcファイルの内容があります:

<%@ ServiceHost Language="C#" Debug="true" Service="EcuWeb.ServiceLib.Contracts.EcuWebServiceMain" %>

以下は私のWeb.configです:

<?xml version="1.0"?>
  <configuration>
<configSections>
    <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</configSections>
  <appSettings>
     <add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
  </appSettings>
 <system.web>
   <compilation debug="true" targetFramework="4.5" />
   <httpRuntime targetFramework="4.5"/>
 </system.web>
<system.serviceModel>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" minFreeMemoryPercentageToActivateService="1" multipleSiteBindingsEnabled="true"/>
    <services>
        <service name="EcuWeb.ServiceLib.Contracts.EcuWebServiceMain">
            <endpoint address="net.tcp://localhost:808/EcuWebService/service" binding="netTcpBinding" bindingConfiguration="" name="netTcp_EcuWebServiceEndpoint" contract="EcuWeb.ServiceLib.Contracts.IEcuWebServiceMain">
                <identity>
                    <dns value="localhost" />
                </identity>
            </endpoint>
            <endpoint address="net.tcp://localhost:808/EcuWebService/mex" binding="mexTcpBinding" bindingConfiguration="" name="mexTcp_EcuWebServiceEndpoint" contract="IMetadataExchange" />
            <host>
               <baseAddresses>
                  <add baseAddress="http://localhost/EcuWebService" />
                </baseAddresses>
            </host>
        </service>
    </services>
    <behaviors>
        <serviceBehaviors>
            <behavior name="">
                <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
                <serviceDebug includeExceptionDetailInFaults="true" />
            </behavior>
        </serviceBehaviors>
    </behaviors>
</system.serviceModel>

これは、クライアント アプリの構成です。コメントアウトされたエンドポイントは、IIS でホストしていないときに使用するエンドポイントであり、動作します。

<?xml version="1.0" encoding="utf-8" ?>
  <configuration>
    <system.web>
      <compilation debug="true" />
    </system.web>
     <!-- When deploying the service library project, the content of the config file    must be added to the host's 
          app.config file. System.Configuration does not support config files for libraries. -->
     <system.serviceModel>
       <bindings>
        <netTcpBinding>
          <binding name="netTcp_EcuWebServiceEndpoint" />
        </netTcpBinding>
       </bindings>
     <client>
      <!--<endpoint address="net.tcp://localhost:5555/EcuWebService/service"
       binding="netTcpBinding" bindingConfiguration="netTcp_EcuWebServiceEndpoint"
       contract="EcuWebService.IEcuWebServiceMain" name="netTcp_EcuWebServiceEndpoint">
        <identity>
         <dns value="localhost" />
        </identity>
       </endpoint>-->
         <endpoint address="net.tcp://localhost/EcuWebService/service"
            binding="netTcpBinding" bindingConfiguration="netTcp_EcuWebServiceEndpoint"
            contract="EcuWebService.IEcuWebServiceMain"    name="netTcp_EcuWebServiceEndpoint">
            <identity>
                <dns value="localhost" />
            </identity>
        </endpoint>
</client>
<services>
  <service name="Ecu.Service.Contracts.EcuServiceMain">
    <endpoint address="service" binding="netNamedPipeBinding" bindingConfiguration=""
      name="netNamedPipe_EcuClientEndpoint" contract="Ecu.Service.Contracts.IEcuServiceMain">
      <identity>
        <dns value="localhost" />
      </identity>
    </endpoint>
    <endpoint address="mex" binding="mexNamedPipeBinding" bindingConfiguration=""
      name="mexNamedPipe_EcuClientEndpoint" contract="IMetadataExchange" />
    <host>
      <baseAddresses>
        <add baseAddress="net.pipe://localhost/EcuServiceClient" />
      </baseAddresses>
    </host>
  </service>
</services>
<behaviors>
   <serviceBehaviors>
     <behavior name="">
       <serviceMetadata httpGetEnabled="false" />
         <serviceDebug includeExceptionDetailInFaults="true" />
     </behavior>
   </serviceBehaviors>
 </behaviors>

4

2 に答える 2

1

わかりました、私はついにこれを理解しました。

最初に追加する必要がありました:

<host>
 <baseAddresses>
  <add baseAddress="net.tcp://localhost:5555/EcuWebService" />
  <add baseAddress="http://localhost/EcuWebService" />
 </baseAddresses>
</host>

次に、使用したエンドポイントについて:

<service name="EcuWeb.ServiceLib.Contracts.EcuWebServiceMain">
<endpoint address="service" binding="netTcpBinding" bindingConfiguration=""
 name="netTcp_EcuWebServiceEndpoint" contract="EcuWeb.ServiceLib.Contracts.IEcuWebServiceMain">
 <identity>
  <dns value="localhost" />
 </identity>
</endpoint>

次に、クライアントで使用する必要がありました。

<endpoint address="net.tcp://localhost/EcuWebService/Service.svc/service"
    binding="netTcpBinding" bindingConfiguration="netTcp_EcuWebServiceEndpoint"
    contract="EcuWebService.IEcuWebServiceMain" name="netTcp_EcuWebServiceEndpoint">
            <identity>
                <dns value="localhost" />
            </identity>
        </endpoint>

ポートを追加したときは機能しませんでしたが、削除すると問題なく機能しました。また、IISがとにかくアドレスを提供しているので、ベースアドレスが必要かどうかは疑問です。

于 2013-02-13T16:21:28.953 に答える