2012-03-23 69 views
0

我想讓https安全工作爲我在IIS 7.5託管的wcf Web服務工作。我瀏覽了每一篇關於這方面可以在網上找到的文章,並且嘗試了幾乎所有可以找到或變化的配置或IIS技巧。我認爲這可能是一個IIS,Windows級別的配置問題。我們正在使用通配符SSL證書,如* .mycompany.com。如果有任何方位,此證書已在其他3個已在同一IIS中的網站上使用。有誰知道我在這裏遇到什麼?這是一個公共服務器,非TEST和http綁定工作正常。我在我的開發和生產服務器上有這個相同的https問題。我們在這個生產箱上有另一個https網站,它發送和接收數據都很好。我得到異常:獲取404沒有端點偵聽錯誤WCF 4.0使用Https basicHttpBinding在傳輸安全

There was no endpoint listening at https://subdomain.mydomain.com/MyService.svc that could accept the message. This is often caused by an incorrect address or SOAP action.

Inner Exception :

The remote server returned an error: (404) Not Found.

這裏是我的web.config

<?xml version="1.0" encoding="UTF-8"?> 
<configuration> 
    <appSettings file="LocalAppSettings.config"> 
     <!--<add key="CustomIISServiceHostEndPoint" value="https://subdomain.mydomain.com/MyService.svc" />--> 
    </appSettings> 
    <system.web> 
     <compilation debug="true" targetFramework="4.0" /> 
     <customErrors mode="Off" /> 
    </system.web> 
    <system.serviceModel> 
     <bindings> 
    <basicHttpBinding> 
    <binding name="COLWebServiceBinding" maxReceivedMessageSize="134217727" sendTimeout="00:03:00" receiveTimeout="00:03:00"> 
     <security mode="Transport"> 
      <transport clientCredentialType="None" /> 
     </security> 
     <readerQuotas maxArrayLength="65536" maxBytesPerRead="65536" maxStringContentLength="134217727" /> 
    </binding> 
    </basicHttpBinding> 
</bindings> 
<services> 
    <service behaviorConfiguration="COLWebService.ServiceBehavior" name="COLWebService"> 
    <endpoint address="https://subdomain.mydomain.com/MyService.svc" 
       binding="basicHttpBinding" 
       contract="MyCompany.COLWebService.ICOLWebService" 
       bindingConfiguration="COLWebServiceBinding" /> 
    <endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange" /> 
    </service> 
</services> 
<extensions> 
    <behaviorExtensions> 
    <add name="errorHandler" type="MyCompany.COLWebService.ErrorHandlerBehaviorExtensionElement, MyCompany.COLWebService" /> 
    </behaviorExtensions> 
</extensions> 
<behaviors> 
    <serviceBehaviors> 
    <behavior name="COLWebService.ServiceBehavior"> 
     <serviceMetadata httpsGetEnabled="true" /> 
     <serviceDebug includeExceptionDetailInFaults="true" /> 
    </behavior> 
    <!--<behavior name=""> 
     <serviceMetadata httpGetEnabled="true" /> 
     <serviceDebug includeExceptionDetailInFaults="true" /> 
    </behavior>--> 
    </serviceBehaviors> 
</behaviors> 
<serviceHostingEnvironment multipleSiteBindingsEnabled="false"> 
</serviceHostingEnvironment> 
</system.serviceModel> 
<system.webServer> 
    <modules runAllManagedModulesForAllRequests="true" /> 
    </system.webServer> 
</configuration> 

這裏是我的客戶的app.config

<?xml version="1.0" encoding="utf-8" ?> 
<configuration> 
    <system.serviceModel> 
     <bindings> 
      <basicHttpBinding> 
       <binding name="wsHttpBinding_ICOLWebService" closeTimeout="00:01:00" 
       openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:03:00" 
       allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" 
       maxBufferPoolSize="524288" maxReceivedMessageSize="134217727" 
       messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true"> 
         <readerQuotas maxStringContentLength="134217727" maxArrayLength="65536" 
        maxBytesPerRead="65536" /> 
         <security mode="Transport"> 
          <transport clientCredentialType="None" proxyCredentialType="None" /> 
        </security> 
       </binding> 
      </basicHttpBinding> 
     </bindings> 
     <client> 
      <endpoint address="https://subdomain.mydomain.com/MyService.svc" 
      binding="basicHttpBinding" bindingConfiguration="wsHttpBinding_ICOLWebService" 
      contract="COLWebService.ICOLWebService" name="wsHttpBinding_ICOLWebServiceEP" /> 
      </client> 
    </system.serviceModel> 
    </configuration> 
+0

您是否嘗試過剛剛打開瀏覽器並導航到SVC地址?我經常發現比試圖解決WCF錯誤更多的信息。 – 2012-03-23 17:46:49

+0

是的,如果我只有https綁定它似乎導航好,但MEX關閉,即使我已打開配置文件中的MEXHttps。但它應該在有或沒有mex的情況下工作。 – kyleb 2012-03-23 18:57:25

+0

我認爲這可能是因爲我使用UI來爲每個站點分配通配符證書,而不是使用命令行。不,我去了,並刪除了所有我的網站上的所有https綁定,然後將它們全部綁定到https,使用本站告訴我的命令行使用相同的通配符證書。 http://www.sslshopper.com/article-ssl-host-headers-in-iis-7.html。就像這個appcmd set site /site.name:「」/+bindings.[protocol='https',bindingInformation ='*:443:'] – kyleb 2012-03-26 02:07:19

回答

0

您可以通過修改手動添加主機頭值SSL證書system32 \ inetsrv中的applicationhost.config文件。查找您的IIS實例的部分。

+0

根本沒有幫助 – kyleb 2012-03-23 18:56:30

0

可能是https綁定尚未配置爲新站點。

在IIS中,選擇該站點,然後單擊高級設置並檢查綁定的內容。確保https在列表中。

編輯

其他的事情,它可能是是在SVC處理程序沒有被激活。 ASP.Net是否打開了該網站?

您應該首先不使用https進行測試,以確保問題與https相關。

編輯2

確保該網站已啓動。你有沒有檢查過你可以通過瀏覽器訪問svc?

您在機器上有幾個站點,都使用https。您是否配置了主機標頭以允許所有網站使用https?在此站點上的https是否在不同的端口上?

+0

我已經做到了 – kyleb 2012-03-23 18:56:13

+0

我沒有https測試,它工作正常。 – kyleb 2012-03-25 00:35:43

+0

它已啓動。是的,我有。它在瀏覽器中顯示,但它說Mex關閉,因爲我只有https mex綁定而不是http。但我只想要https。是的,所有站點都在此IIS服務器上使用與* .mycompany.com通配符證書相同的https。他們都使用端口443作爲他們的https端口。 – kyleb 2012-03-25 15:03:23

0

打開.svc文件 - 我猜它沒有引用COLWebService作爲服務。

您的配置文件有:

name="COLWebService" 
在服務聲明

。這需要與.SVC的指定服務相匹配,該服務會查看您提供的網址,我認爲這將是'MyService'。

+0

我剛剛更改了發佈在線目的的東西名稱。它的確如你所說的我想的相匹配,但我會仔細檢查。 – kyleb 2012-03-25 00:35:17

0

您的服務模型部分應該是這樣的

<system.serviceModel> 
    <behaviors> 
     <serviceBehaviors> 
     <behavior name=""> 
      <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" httpsGetUrl="/ssl"/> 
      <serviceDebug includeExceptionDetailInFaults="false"/> 
      <dataContractSerializer maxItemsInObjectGraph="6553600" /> 
     </behavior> 
     </serviceBehaviors> 
    </behaviors> 
    <bindings> 
     <basicHttpBinding> 
     <binding name="TransportSecurity" maxReceivedMessageSize="2147483647"> 
      <security mode="Transport"> 
      <transport clientCredentialType="None"/> 
      </security> 
     </binding> 
     </basicHttpBinding> 
    </bindings> 
    <services> 
     <service name="COLWebService.Service" behaviorConfiguration=""> 
     <endpoint address="/ssl" binding="basicHttpBinding" bindingConfiguration="TransportSecurity" contract="MyCompany.COLWebService.ICOLWebService"/> 
     <endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange"/> 
     </service> 
    </services> 
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" /> 
    </system.serviceModel> 

和您的客戶將訪問SERVIS通過HTTPS https://subdomain.mydomain.com/MyService.svc/ssl,通過HTTP一樣老https://subdomain.mydomain.com/MyService.svc

+0

爲什麼我需要https的/ ssl?爲什麼他們不能使用相同的地址,只需將url的第一部分改爲http或https?它應該只是在IIS中自動處理併爲我映射。 – kyleb 2012-03-26 02:14:25

+0

端點地址應該是唯一的,所以http和https地址必須不同http://msdn.microsoft.com/en-us/library/ms733107.aspx。這是它爲我工作的方式,還有另一篇文章你可能想看http://stackoverflow.com/a/1989478/1175585 – 2012-03-26 05:45:38

+0

嗯。你有沒有試過只使用基本的HttpBinding或wsHttpBinding使用Tranport安全模式,而不是使用HttpTransport節點元素的自定義綁定?此外,我只希望通過https提供此服務,而不是http。 – kyleb 2012-03-26 14:36:15