簡體   English   中英

從局域網中的另一台計算機訪問我的WCF服務

[英]Accessing my WCF service from another machine in a LAN

我一直在尋找解決問題的方法,嘗試了各種建議,但到目前為止,沒有一個對我有用。

我可以在本地很好地訪問WCF服務,但似乎無法從普通LAN網絡中的另一台計算機訪問它。

注意:我不是WCF方面的專家,但是在研究中做出了應有的貢獻。 我嘗試了不同的綁定, netTcpBinding對我不起作用,因為我收到不支持它的錯誤。

另外,我的防火牆已關閉,因此我很確定它不是防火牆問題,而且我是Visual Studio的內置Web服務器,我不確定如何通過IIS托管它,或者從哪里開始那。

<system.serviceModel>
<services>
  <service name="WCFService.TorrentService">
    <endpoint contract="WCFService.ITorrentService"
              address="TorrentService"
              binding="basicHttpBinding">
    </endpoint>
    <endpoint address="TorrentService/MEX/"
              binding="mexHttpBinding"
              contract="IMetadataExchange">
    </endpoint>
    <host>
      <baseAddresses>
        <add baseAddress="http://192.168.7.111:3697/TorrentService"/>
      </baseAddresses>
    </host>
  </service>
</services>
<behaviors>
  <serviceBehaviors>
    <behavior>
      <!-- To avoid disclosing metadata information, set the values below to false before deployment -->
      <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
      <!-- To receive exception details in faults for debugging purposes, set the value below to true.  Set to false before deployment to avoid disclosing exception information -->
      <serviceDebug includeExceptionDetailInFaults="false"/>
      <useRequestHeadersForMetadataAddress>
        <defaultPorts>
          <add scheme="http" port="3697" />
        </defaultPorts>
      </useRequestHeadersForMetadataAddress>
    </behavior>
  </serviceBehaviors>
</behaviors>
<protocolMapping>
    <add binding="basicHttpBinding" scheme="https" />
</protocolMapping>    
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />

我很確定配置文件中不應該包含很多內容,因為我嘗試了許多不同的解決方案,但到目前為止,沒有任何一個對我有用。

當我嘗試從另一台機器訪問服務時,請執行以下操作

http://s8.postimg.org/yqps7k6f9/untitled.png
http://s8.postimg.org/yqps7k6f9/untitled.png

如果您的wcf在本地主機上工作,則問題是與其他計算機共享它。 我相信您使用的是標准開發服務器或IIS Express。 存檔所需內容的一種方法是使用IIS Express,然后閱讀下一篇文章http://johan.driessen.se/posts/Accessing-an-IIS-Express-site-from-a-remote-computer

一旦為IIS Express和機器上的安全性進行了所有必要的設置,我相信您將獲得對wcf服務的評估。 但是嘗試兩種方法:使用IP地址和計算機名稱!!!

請啟動您的項目,然后從另一台計算機訪問。 從另一台計算機訪問主機服務之前,該主機服務應已運行。

暫無
暫無

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

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