[英]Expose WCF Web service on the internet configuration
我試圖將用WCF編寫的Web服務公開給開放的Internet,但是我無法配置它以從外部URL使用。
該Web服務內部托管在https://ourportal.internaldomain.intra:9011 / FrontEndWS上,並且運行良好。 我們已經在https://www.internetdomain.com.mt/FrontEndWS上公開了該Web服務,但是當從外部地址訪問該Web服務時,Soap URL仍然引用內部地址。
我們的設置如下。 我們不需要內部公開Web服務,而只需要在Internet上公開,這樣可以簡化配置。
<bindings>
<basicHttpBinding>
<binding name="LargeMessagingBinding" maxBufferSize="99999900" maxBufferPoolSize="524288000" maxReceivedMessageSize="99999900">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="99999900" maxBytesPerRead="99999900" maxNameTableCharCount="2147483647" />
<security>
<transport clientCredentialType="Basic" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="ServiceBehaviour">
<serviceMetadata httpGetEnabled="false" httpsGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
<dataContractSerializer maxItemsInObjectGraph="6553600" />
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment aspNetCompatibilityEnabled="false" multipleSiteBindingsEnabled="false" />
為了將您的Web服務公開給外部世界,您需要將WCF服務放在IIS中網站下的虛擬目錄中。
現在,您的URL“ www.internetdomain.com.nt
”將被映射到特定的IP地址(可外部訪問),並且此IP地址是WCF服務所在的服務器的IP地址。
IIS收到此IP上的任何請求,並確定如何處理該請求。
如果以上情況都很好,那么您的WCF服務的URL將是:
http://www.internetdomain.com.nt/virtualdirectory/FrontEndWS
https://www.internetdomain.com.nt/virtualdirectory/FrontEndWS
對於https
情況,您的網站將通過“ Edit Bindings
選項映射443 https端口,並指定它需要使用的服務證書。
另外,您還需要在web.config中使用端點定義服務。 示例如下所示:
<bindings>
<basicHttpBinding>
<binding name="LargeMessagingBinding" maxBufferSize="99999900" maxBufferPoolSize="524288000" maxReceivedMessageSize="99999900">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="99999900" maxBytesPerRead="99999900" maxNameTableCharCount="2147483647" />
<security>
<transport clientCredentialType="Basic" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<services>
<service name="SampleWCFService.Service1" behaviorConfiguration="default">
<endpoint address="" behaviorConfiguration="ServiceBehaviour" binding="basicHttpBinding" bindingConfiguration="LargeMessageBinding" contract="SampleWCFService.IService1"/>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="ServiceBehaviour">
<serviceMetadata httpGetEnabled="false" httpsGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
<dataContractSerializer maxItemsInObjectGraph="6553600" />
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment aspNetCompatibilityEnabled="false" multipleSiteBindingsEnabled="false" />
檢查以上配置中的services元素。 確保正確指定了服務的名稱空間。
我遇到了同樣的問題,現在發現這是由於Web服務器前端的SSL卸載程序。 請與您的管理員組聯系。 我們擺脫了SSL卸載程序,因為我們不得不補充服務。 您可以參考以下鏈接
http://blogs.msdn.com/b/distributedservices/archive/2010/05/13/wcf-and-intermediate-devices.aspx
同時添加https的主機頭
http://www.sslshopper.com/article-ssl-host-headers-in-iis-7.html
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.