【问题标题】:WCF service is not accessible outside of local computerWCF 服务在本地计算机之外无法访问
【发布时间】:2012-12-11 16:51:25
【问题描述】:

我将 WCF 服务 (.NET 3.5) 部署到 IIS 5.1 (WinXP),并且可以从本地计算机访问它。但是,它无法在本地计算机之外访问。

这是我的 web.config 文件:

<system.serviceModel>
  <serviceHostingEnvironment>
    <baseAddressPrefixFilters>
      <add prefix="http://222.22.22.222:8072/"/>
    </baseAddressPrefixFilters>
  </serviceHostingEnvironment>
  <behaviors>
    <serviceBehaviors>
      <behavior name="Parus.ServiceBehavior">
        <serviceMetadata httpGetEnabled="true" httpGetUrl="http://111.1.11.111:8072/AsurReceiveData/Service.svc"/>
        <serviceDebug includeExceptionDetailInFaults="true"/>
        <MyInspector />
      </behavior>
    </serviceBehaviors>
  </behaviors>
  <services>
    <service behaviorConfiguration="Parus.ServiceBehavior" name="Parus.Service">
      <endpoint address="http://222.22.22.222:8072/AsurReceiveData/Service.svc" binding="basicHttpBinding" contract="Parus.IService">
      </endpoint>
      <endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange"/>
    </service>
  </services>
  <extensions>
    <behaviorExtensions>
      <add name="MyInspector" type="Parus.MessageInspectorExtension, Parus, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"/>
    </behaviorExtensions>
  </extensions>
</system.serviceModel>

计算机的本地IP地址为:111.1.11.111:8072。 计算机的公网IP地址为:222.22.22.222:8072。

我做了什么?我在 IIS 5.1 中添加了新的 TCP 端口(默认网站属性 -> 网站选项卡 -> 单击高级按钮 -> 单击添加按钮并添加新端口:8072)。

项目网址如下:

http://111.1.11.111:8072/ServiceFolder

服务如下:

public class Service : IService
{
    public const string ReplyAction = "http://222.22.22.222:8072/AsurReceiveData/Message_ReplyAction";
    public const string RequestAction = "http://222.22.22.222:8072/AsurReceiveData/Message_RequestAction";

    public Message SetData(Message requestXml)
    {
        using (StreamWriter writer = File.CreateText(@"Path\Body.xml"))
        {
            writer.WriteLine(requestXml.ToString());
        }
        Message response = Message.CreateMessage(MessageVersion.Default, ReplyAction, requestXml.ToString());

        return response;
    }
}

我不确定我是否正确使用本地和公共 IP 地址。也许是别的东西……

感谢您的帮助。

【问题讨论】:

  • 为什么没人回答问题?
  • 你没有指定你得到了什么错误,但我首先要检查的是端口 8072 是否允许通过防火墙。
  • 错误是:HTTP 404,找不到资源。
  • 您使用什么作为您的客户?元数据仅在您的内部地址上公开,因此您需要使用 wcf 客户端,例如,您将无法在 WSDL 上执行 HTTP GET。
  • 为什么我不能?例如,我可以使用其他一些外部服务来获得它的功能。为什么我无法将我的服务设置为以相同的方式使用?

标签: wcf deployment


【解决方案1】:

您的计算机上有防火墙,可以阻止所有来电。您应该关闭防火墙或打开 8072 端口,以便能够从其他计算机与您的 wcf 服务进行通信。

【讨论】:

  • 将新端口 8072 添加到防火墙的“例外”部分并进行检查。我可以访问部署到 IIS 的应用程序中的一些普通页面,例如一些 .html 页面。但是,我无法访问 WCF 服务。
猜你喜欢
  • 2020-07-12
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-12-19
  • 2017-12-05
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多