簡體   English   中英

在同一網絡上的其他計算機上調用WCF服務不起作用

[英]invoke WCF service on other machines on the same network not working

我在本地計算機上運行了WCF服務

一切主題都運行正常

問題是

如果我可以在我的本地計算機瀏覽器上調用此WCF服務,為什么它在其他計算機上不可用

我試過的:

  1. 我的服務地址是localhost :另一台機器上的port我用運行我的WCF服務的機器的ip替換了本地主機,但是它沒有工作
  2. 在我的App.config我更改了baseaddress ,如下所示,從localhost到機器ip,它也無法正常工作
  3. 我創建了一個Web應用程序並使用getJson調用我的服務,它在我的本地機器瀏覽器上運行,而不是在任何其他機器上它加載整個頁面並在getJson上給我錯誤

我在這里失蹤了什么? 我不知道

IService1.cs

[OperationContract]
[WebGet(UriTemplate = "GetName/{name}",
        ResponseFormat = WebMessageFormat.Json)]
List<Eval> GetName(string name);

App.config中

<system.web>
    <compilation debug="true"  targetFramework="4.0" />
</system.web>
 <system.webServer>
  <modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
<system.serviceModel>
    <bindings>
        <webHttpBinding>
            <binding name="webHttpBindingWithJsonP" crossDomainScriptAccessEnabled="true"></binding>
        </webHttpBinding>
    </bindings>
    <services>
        <service name="WcfServiceLibrary1.Service1">
            <host>
                <baseAddresses>
                    <add baseAddress = "http://192.168.1.5:8733/Design_Time_Addresses/WcfServiceLibrary1/Service1/" />
                </baseAddresses>
            </host>
            <endpoint address="" binding="webHttpBinding" bindingConfiguration="webHttpBindingWithJsonP" contract="WcfServiceLibrary1.IService1" behaviorConfiguration="web">
                <identity>
                    <dns value="localhost"/>
                </identity>
            </endpoint>
            <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
        </service>
    </services>
    <behaviors>
        <serviceBehaviors>
            <behavior>
                <serviceMetadata httpGetEnabled="True"/>
                <serviceDebug includeExceptionDetailInFaults="False" />
            </behavior>
        </serviceBehaviors>
        <endpointBehaviors>
            <behavior name="web">
                <webHttp/>
            </behavior>
        </endpointBehaviors>
    </behaviors>
</system.serviceModel>

WCF測試客戶端

在此輸入圖像描述

瀏覽器 在此輸入圖像描述

可能是防火牆正在停止服務呼叫。 在托管WCF的計算機上的端口8733上打開入站連接。 如果是Windows,請打開“高級安全Windows防火牆”對話框,在左窗格中單擊“入站規則”,然后在右窗格中單擊“新建規則”並選擇“端口”選項。

暫無
暫無

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

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