簡體   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