[在IIS中使用URL重写时,不能公开访问Web服务

问题描述 投票:0回答:1

我在专用服务器上托管了Web服务。然后,我在公用服务器(互联网服务器)中的IIS中创建了URL重写规则。

[每次我访问URL时,它都会在浏览器上的URL中而不是公共url / IP中显式显示私有服务器的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中的引用。?

web-services http url-rewriting iis-8
1个回答
0
投票

似乎您正在IIS中部署WCF服务。那是对的吗?如果发生错误“example.svc does not exists”,请确保已启用某些Windows功能,以便在IIS中托管WCF服务。enter image description here之所以无法将其添加为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而非公共URL / IP中显式显示私有服务器的IP /计算机名称。

为了使用主机名/域名URL访问服务,我们应确保域名指向服务器的公共IP。这是一个与网络有关的问题。enter image description here

随时让我知道问题是否仍然存在。

© www.soinside.com 2019 - 2024. All rights reserved.