簡體   English   中英

使“添加服務引用”>“發現”工作的最低配置

[英]Minimum configuration to make “Add Service Reference > Discover” work

我已經測試了一些WCF + Windows服務並且在遠程開發機器上作為Windows服務運行正常工作。 除了一個。

為了調試,我嘗試使用內置的“添加服務引用”來托管WCF(沒有Windows服務),然后將其托管在visual studio中(不知道主機的調用方式)。

無論如何,我無法獲得添加服務參考來發現我的服務。

由於我使用的是Windoes服務,我使用的是TCP。 這是我已經完成的一些事情, 所有這些都在我添加服務引用的winforms應用程序中

添加項目>屬性>調試>命令行參數:/client:“WTfTestClient.exe”但exe不運行。

還有我的App.Config

<?xml version="1.0"?>
<configuration>
  <system.serviceModel>
    <client>
      <endpoint address="net.tcp://localhost:32279/SYNC" binding="netTcpBinding"
        bindingConfiguration="tcpSyncBindingConfig" contract="Company.Data.Sync.ILocalCacheSyncContract"
        name="tcpSyncClientEP" />
    </client>
    <bindings>
      <netTcpBinding>
        <binding name="tcpSyncBindingConfig" maxReceivedMessageSize="6553600" />
      </netTcpBinding>
      <mexTcpBinding>
        <binding name="tcpMexBindingConfig" />
      </mexTcpBinding>
    </bindings>
    <services>
      <service behaviorConfiguration="svcBehavior" name="Company.Data.Sync.Services.LocalCacheSyncService">
        <endpoint address="net.tcp://localhost:32279/Sync" binding="netTcpBinding"
          bindingConfiguration="tcpSyncBindingConfig" name="tcpSyncListenEP"
          contract="Company.Data.Sync.Services.ILocalCacheSyncContract" />
        <endpoint address="net.tcp://localhost:32279/Sync/mex" binding="mexTcpBinding"
          bindingConfiguration="tcpMexBindingConfig" name="tcpMexEP" contract="IMetadataExchange" />
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior name="svcBehavior">
          <serviceMetadata httpGetEnabled="false" />
          <serviceDebug includeExceptionDetailInFaults="true" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>
</configuration>

附注 :ServiceOperation正在返回Microsoft.Synchronization.Data.xxx sutff,例如SyncContext。 我可能要在Winforms中添加引用? 或者“添加服務參考”會為我添加它們嗎? 服務和合同由本地數據庫緩存模板生成。 也許與問題無關。

發布后,我繼續尋找答案,這是我嘗試工作的原因:

項目文件本身例如* .csproj for C#項目必須包含用於WCF的ProjectTypeGuid,以便Visual Studio甚至開始檢查項目的服務。

<ProjectTypeGuids>{3D9AD99F-2412-4246-B90B-4EAA41C64699};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>

可以在http://www.mztools.com/articles/2008/mz2008017.aspx找到更多GUID。 (謝謝mztools!)

WCF項目可以有多個服務,每個服務都需要在項目的App.Config中定義其配置。 每個服務都需要具有不同的mex端點地址。 服務還可以共享單個servicebehavior,其中定義了serviceMetadata擴展。 Mex端點不需要行為或綁定配置。 但請記住將mex端點合約設置為IMetadataExhchange。

對於TCP mex,serviceMetadata> HttpGetEnabled必須設置為false。

我相信這是最低限度的設置。

右鍵單擊要在PC上托管的服務,然后右鍵單擊並運行Debug> Start New Instance

然后去你的其他應用程序(我假設相同的解決方案)並復制它運行的URL。

然后,您可以使用上面相同的方法啟動它,並在本地計算機上調試這兩個項目。

我認為這是你想要做的。 請告訴我這是不是別的。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM