繁体   English   中英

在 IIS 中使用 URL 重写时,Web 服务无法公开访问

[英]Webservice is not accessible publicly when using URL rewrite in IIS

我在私人服务器中托管了网络服务。 然后我在公共服务器(互联网服务器)中的 IIS 中创建了 URL 重写规则。

每次我访问 URL 时,它都会在浏览器上的 URL 中明确显示私有服务器的 ip/计算机名称,而不是公共 url/IP。 当我单击 URL 以查看脚本时,它显示“Example.svc 不存在”错误。

当我尝试通过在其中传递 URL 将其添加为 Visual Studio 中的服务引用时,它也不起作用。 它引发以下错误。

The request failed with HTTP status 400: Bad request
Metadata contains a reference that cannot be resolved: <SERVER URL>
The remote server turned an unexpected response: (405) Method not allowed.

我应该怎么做才能公开访问 URL 并且还能够将其添加为 Visual Studio 中的参考。?

您似乎正在 IIS 中部署 WCF 服务。 那是对的吗? 如果出现“example.svc does not exists”错误,请确保您已启用某些 Windows 功能,以便在 IIS 中托管 WCF 服务。
在此处输入图像描述
我们无法将其添加为Service Reference以调用服务的原因是我们尚未发布元数据服务端点。 这取决于您的 WCF 服务类型。 通常,我们要么添加 Mex 服务端点,要么通过添加元数据服务行为发布服务 WSDL。

  <services>
    <service name="WcfService1.Service1">
      <endpoint address="" binding="basicHttpBinding" bindingConfiguration="mybinding" contract="WcfService1.IService1">
      </endpoint>
      <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"></endpoint>
    </service>
  </services>

  <behaviors>
        <serviceBehaviors>
          <behavior>
            <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />

每次我访问 URL 时,它都会在浏览器上的 URL 中明确显示私有服务器的 ip/计算机名称,而不是公共 url/IP。

为了使用主机名/域名URL访问服务,我们应该确保域名指向服务器的公共IP。 这是一个与网络相关的问题。 在此处输入图像描述

如果问题仍然存在,请随时告诉我。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM