0

WCF に問題があります。私のサービス契約インターフェイスは次のとおりです。

namespace A.B.C
{
    [ServiceContract]
    public interface IWSpExporter
    {
        [OperationContract]
        int ExportFile();

        [OperationContract]
        int ExportMetaData();

        [OperationContract]
        int ExportAll();
    }
}

そしてもちろん、私はクラスを持っています:

namespace A.B.C
{
    class WSpExporter : IWSpExporter
    {

        public int ExportFile() 
        {
            return 0;
        }

        public int ExportMetaData()
        {
            return 0;
        }

        public int ExportAll()
        {
            return 0;
        }
    }
}

そして、私の App.config は次のとおりです。

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <system.serviceModel>
    <services>

      <service name="A.B.C.WSpExporter"
               behaviorConfiguration="WSpExporterBehavior">
        <host>
          <baseAddresses>
            <add baseAddress="http://localhost:8000/WSpExporter/service"/>
          </baseAddresses>
        </host>

        <!-- this endpoint is exposed at the base address provided by host: http://localhost:8000/WSpExporter/service-->
        <endpoint address=""
                  binding="wsHttpBinding"
                  contract="A.B.C.IWSpExporter">
          <identity>
            <servicePrincipalName value="host/localhost"/>
          </identity>
        </endpoint>

        <!-- this endpoint is exposed at the base address provided by host: http://localhost:8000/WSpExporter/service/mex -->
        <endpoint address="mex" 
                  binding="mexHttpBinding" 
                  contract="IMetadataExchange" />

      </service>
    </services>

    <behaviors>
      <serviceBehaviors>
        <behavior name="WSpExporterBehavior">
          <serviceMetadata httpGetEnabled="true"/>
          <serviceDebug includeExceptionDetailInFaults="False"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>
</configuration>

次に、サービスをコンパイルしてインストールします。起動されたすべてのサービスを確認できるWindows GUIで正しく起動されていることがわかります...

しかし、 : にアクセスしようとするとhttp://localhost:8000/WSpExporter/service、結果がありません。

サービスを WcfTestClient に追加しようとすると、次のエラーが発生します。

サービスの追加に失敗しました。サービス メタデータにアクセスできない場合があります。サービスが実行中で、メタデータを公開していることを確認してください。

どこに問題があるのか​​ わかりません...

編集:(すべてのサービスコードはここにはありません...)

namespace A.B.C
{
class PExporter : ServiceBase
{
  public static void Main()
    {
        ServiceBase.Run(new PExporter());
    }

    protected override void OnStart(string[] args)
    {

        if (serviceHost != null)
        {
            serviceHost.Close();
        }

        serviceHost = new ServiceHost(typeof(PExporter));

        serviceHost.Open();
    }

    protected override void OnStop()
    {
        if (serviceHost != null)
        {
            serviceHost.Close();
            serviceHost = null;
        }
    }
}
}
4

1 に答える 1