【问题标题】:Self hosted wcf service inside wpf application - can't call / run through browserwpf 应用程序内的自托管 wcf 服务 - 无法通过浏览器调用/运行
【发布时间】:2014-04-29 14:02:30
【问题描述】:

我在 WPF 应用程序中托管了一个名为“FaceDetectionService”的 WCF 服务,它实现了接口 IFaceDetectionService。我在 MainWindow 的构造函数中使用以下代码托管了该服务:

    ServiceHost servicehostFaceDetectionRequired = new ServiceHost(typeof(FaceDetectionService));
    servicehostFaceDetectionRequired.Open();

这是我的 app.config:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
    <startup> 
        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
    </startup>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="Microsoft.Kinect" publicKeyToken="31bf3856ad364e35" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-1.8.0.0" newVersion="1.8.0.0" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
<system.serviceModel>
        <behaviors>
            <serviceBehaviors>
                <behavior name="">
                    <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
                    <serviceDebug includeExceptionDetailInFaults="false" />
                </behavior>
            </serviceBehaviors>
        </behaviors>

        <services>      


          <service name="FacialRecognitionTest.FaceDetectionService">
            <endpoint address="" binding="basicHttpBinding" contract="FacialRecognitionTest.IFaceDetectionService">
              <identity>
                <dns value="localhost" />
              </identity>
            </endpoint>
            <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
            <host>
              <baseAddresses>
                <add baseAddress="http://localhost:8734/Design_Time_Addresses/FacialRecognitionTest/FaceDetectionService/" />
              </baseAddresses>
            </host>
          </service>
        </services>
    </system.serviceModel>
</configuration>

问题:启动应用程序后,我无法浏览到我在 App.config 中提供的 URI。我为 Windows 窗体应用程序的自托管 WCF 服务执行了相同的步骤,它正在工作。有人可以帮忙吗?

谢谢

【问题讨论】:

  • 您是否遇到错误?
  • 不,我没有收到任何错误,但我无法调用服务,也无法在 Web 浏览器中浏览它进行测试。
  • 更新:我尝试使用 WCF 客户端测试服务并收到以下错误:

标签: wpf wcf service


【解决方案1】:

它现在正在工作。我在关闭窗口之前关闭了服务。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-05-17
    • 2017-01-20
    • 1970-01-01
    • 2012-03-16
    • 2014-08-10
    • 2011-11-03
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多