簡體   English   中英

具有不同端點和HTTPS綁定的相同WCF服務

[英]Same WCF service with different EndPoints and Different Bindings For HTTPS

我看過SO上的幾篇文章,這些文章顯示了如何為同一服務添加多個端點,但是沒有一個實際上是在使用HTTPS,這就是為什么我問這個問題。

我有的

我有一個網絡服務,

https://portal.gov.com/us/216/_vti_bin/external/gov.svc

我想要的是

我想使用兩種不同的配置,以及具有不同的ENDPOINTS但具有相同URL?的綁定來調用此Web服務。 (對不起,也許我對Endpoints的概念感到困惑)

這是我的web.config的樣子,

<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<configuration>
  <system.serviceModel>
    <behaviors>
      <serviceBehaviors>
        <behavior name="Gov_ServiceBehavior">
          <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
        </behavior>
      </serviceBehaviors>

      <endpointBehaviors>
        <behavior name="restBehavior">
          <webHttp defaultBodyStyle="Wrapped" defaultOutgoingResponseFormat="Json" automaticFormatSelectionEnabled="true" />
        </behavior>
      </endpointBehaviors>
    </behaviors>

    <bindings>
      <webHttpBinding>
        <binding name="Gov_webHttpBinding">
          <security mode="Transport">
            <transport clientCredentialType="InheritedFromHost" />
          </security>
        </binding>
      </webHttpBinding>
      <!--<basicHttpBinding>
        <binding name="Gov_BasicHttpBinding">
          <security mode="Transport">
            <transport clientCredentialType="InheritedFromHost" />
          </security>
        </binding>
      </basicHttpBinding>-->
    </bindings>

    <services>
      <service name="Portal.WebServices.External.Gov" behaviorConfiguration="Gov_ServiceBehavior">
        <endpoint address="" binding="webHttpBinding" behaviorConfiguration="restBehavior" contract="Portal.WebServices.External.IGov" bindingConfiguration="Gov_webHttpBinding"/>
        <endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange"/>
        <!--<endpoint address="basic" binding="basicHttpBinding" contract="Portal.WebServices.External.IGov" bindingConfiguration="Gov_BasicHttpBinding"/>-->
      </service>
    </services>

  </system.serviceModel>

</configuration>

痛苦在哪里

它只有在我將basicHttpBinding和它的端點注釋掉之后才起作用,一旦包含了它,我就會得到無聲的錯誤。

據此-https://msdn.microsoft.com/en-us/library/ms751515(v=vs.110).aspx

它應該可以工作,但是可能不行,因為我正在使用HTTPS並將BINDINGS標記添加到我的web.Config中。

您試圖實現的目標是不可能的。 您不能將兩個不同的綁定應用於完全相同的端點。 如果您嘗試在此處再次閱讀參考文獻那么很明顯該示例具有兩個不同的端點:

第一個地址是http://localhost/servicemodelsamples/service.svc ,第二個地址是http://localhost/servicemodelsamples/service.svc/secure 這兩個端點互不相同,但共享同一合約。

第二個端點僅相對於基本地址http://localhost/servicemodelsamples/service.svc

我希望這使您對綁定和終結點頭腦清醒。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM