【问题标题】:Cannot access WCF service on Remote server无法访问远程服务器上的 WCF 服务
【发布时间】:2016-08-03 17:25:13
【问题描述】:

我在使用 basicHttpBinding 运行的远程 Windows VPS 中托管了 WCF Web 服务 C#。

问题是我通过远程桌面浏览到服务器计算机上的服务 URL 工作正常,但尝试使用外部 IP 地址(远程或本地)浏览不起作用。 (它向我显示浏览器消息“无法访问此站点”)示例:

http://localhost:99/Service1.svc(好的)

http://8.35.36.82:99/Service1.svc来自服务器远程桌面(OK)

http://8.35.36.82:99/Service1.svc 来自我的机器(不正常)

我已经在服务器防火墙中打开了入站端口

有什么想法吗??

Web.config

  <system.serviceModel>
   <behaviors>
  <serviceBehaviors>
    <behavior>

      <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />

      <serviceDebug includeExceptionDetailInFaults="false" />

    </behavior>
  </serviceBehaviors>
</behaviors>
<protocolMapping>
  <add binding="basicHttpsBinding" scheme="https" />
</protocolMapping>

<services>
  <service name="WebService.Service1">
    <endpoint address="http://8.35.36.82:99/WebService/Service1.svc" binding="BasicHttpBinding" contract="WebService.IService1" />
  </service>
</services>
<serviceHostingEnvironment multipleSiteBindingsEnabled="false"  />
 </system.serviceModel>

【问题讨论】:

  • “不起作用”——迄今为止最好的错误描述。
  • 它向我显示浏览器消息“无法访问此站点”

标签: c# web-services wcf remote-server


【解决方案1】:

你能简单地把它放在你的配置中吗-->

<services>
  <service name="WebService.Service1">
    <endpoint address="" binding="BasicHttpBinding" contract="WebService.IService1" />
  </service>
</services>

【讨论】:

  • 不幸的是,这没有帮助,没有任何改变:(
  • 当您在客户端应用程序中导航到该网址时会发生什么?
  • 同样的状态,我设置了地址 = "" 并且在本地远程服务器上运行良好,无论是 8.35.36.82:99/Service1.svclocalhost:99/Service1.svc,但在我的机器上,不是 8.35.36.82:99/Service1.svc
  • 在本地机器的浏览器中输入8.35.36.82:99/WebService/Service1.svc 时出现什么错误?也可以试试 http 和 https。
  • 相同消息“无法访问此站点 8.35.36.82 响应时间过长。” ..我尝试了http和https ..结果相同,我什至关闭了服务器上的防火墙..没有任何效果:(
【解决方案2】:

我的解决方案

<system.serviceModel>
  <standardEndpoints>
      <webScriptEndpoint>
          <standardEndpoint name="webScriptEndpoint0" crossDomainScriptAccessEnabled="true" />
      </webScriptEndpoint>
  </standardEndpoints>
   <bindings>
    <basicHttpBinding>
      <binding name="basicHttpBinding0">
        <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
          maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
      </binding>
    </basicHttpBinding>
    <webHttpBinding>
      <binding name="webHttpBinding0">
        <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
          maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
      </binding>
    </webHttpBinding>
  </bindings>
  <services>
    <service behaviorConfiguration="debugServiceBehavior" name="Backend.CoreService">
      <endpoint address="" behaviorConfiguration="webHttpRest" binding="webHttpBinding"  bindingConfiguration="webHttpBinding0" name="Unsecure.Backend.CoreService"  contract="Backend.ICoreService" />
    </service>
  </services>
  <behaviors>
    <endpointBehaviors>
      <behavior name="webHttpRest">
        <webHttp helpEnabled="true" automaticFormatSelectionEnabled="true"  faultExceptionEnabled="true" />
      </behavior>
    </endpointBehaviors>
    <serviceBehaviors>
      <behavior name="debugServiceBehavior">
        <serviceMetadata httpGetEnabled="true" />
        <serviceDebug includeExceptionDetailInFaults="true" />
      </behavior>
    </serviceBehaviors>
  </behaviors>
  <protocolMapping>
    <add binding="webHttpBinding" bindingConfiguration="basicHttpBinding0" scheme="http" />
  </protocolMapping>
  <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
</system.serviceModel>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-01-12
    • 2020-03-06
    • 2013-03-17
    相关资源
    最近更新 更多