2015-04-07 73 views
0

我有一個解決方案,其中包含一個WCF Web服務項目和一個WPF客戶端項目,可以在本地正常工作。我有一個專用的IIS Web服務器,我已經部署了WCF Web服務項目。 IIS站點配置有SSL證書,並且設置爲需要SSL。該站點具有HTTPS綁定,綁定到默認端口上的特定DNS主機名和所有IP地址(只有一個)。WCF Web服務客戶端拋出404 EndPointNotFoundException

我可以在服務器或客戶端的瀏覽器中訪問端點地址和WSDL,沒有問題。該組織使用代理服務器,但我認爲這不會妨礙客戶端和服務器之間的防火牆。

這裏是我的服務器上的web.config:

<?xml version="1.0" encoding="UTF-8"?> 
<configuration> 
    <system.serviceModel> 
     <bindings> 
      <wsHttpBinding> 
       <binding name="DefaultBinding" maxReceivedMessageSize="1000000000"> 
        <security mode="Transport"> 
         <transport clientCredentialType="None" proxyCredentialType="None"> 
          <extendedProtectionPolicy policyEnforcement="Never" /> 
         </transport> 
        </security> 
       </binding> 
      </wsHttpBinding> 
     </bindings> 
     <services> 
      <service name="Hca.Ims.Wcf.ImsService"> 
       <endpoint 
       name="Hca.Ims.Wcf.ImsService" 
       address="/ImsService.svc" 
       binding="wsHttpBinding" 
       bindingConfiguration="DefaultBinding" 
       contract="Hca.Ims.DataAccess.DataContracts.IImsDataContract" /> 
      </service> 
     </services> 
     <behaviors> 
      <serviceBehaviors> 
       <behavior> 
        <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" /> 
        <serviceDebug includeExceptionDetailInFaults="true" /> 
       </behavior> 
      </serviceBehaviors> 
     </behaviors> 
     <protocolMapping> 
      <add binding="basicHttpsBinding" scheme="https" /> 
     </protocolMapping> 
     <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="false" /> 
    </system.serviceModel> 
    <system.webServer> 
     <modules runAllManagedModulesForAllRequests="true" /> 
     <directoryBrowse enabled="true" /> 
     <httpErrors errorMode="Detailed" /> 
    </system.webServer> 
</configuration> 

這裏是我的客戶的app.config:

<?xml version="1.0" encoding="utf-8"?> 
<configuration> 
    [...] 
    <system.net> 
     <defaultProxy enabled="false" /> 
    </system.net> 
    <system.serviceModel> 
     <bindings> 
      <wsHttpBinding> 
       <binding name="DefaultBinding" receiveTimeout="00:30:00" 
       sendTimeout="00:30:00" maxReceivedMessageSize="1000000000"> 
        <security mode="Transport"> 
         <transport clientCredentialType="None" proxyCredentialType="None" > 
          <extendedProtectionPolicy policyEnforcement="Never" /> 
         </transport > 
        </security> 
       </binding> 
      </wsHttpBinding> 
     </bindings> 
     <client> 
      <endpoint address="https://mydnsname/ImsService.svc" binding="wsHttpBinding" 
      bindingConfiguration="DefaultBinding" contract="ImsService.IImsDataContract" 
      name="Hca.Ims.Wcf.ImsService" /> 
     </client> 
    </system.serviceModel> 
</configuration> 

這裏是一些調用代碼:

var webClient = new System.Net.WebClient(); 
//Works 
var webResult = webClient.DownloadString("https://mydnsname/ImsService.svc"); 

var wcfClient = new ImsDataContractClient("Hca.Ims.Wcf.ImsService"); 
//Crashes 
var wcfResult = wcfClient.GetUserInfo("SomeUserId"); 

結果:

EndPointNotFoundException: 在https://mydnsname/ImsService.svc處沒有可以接受消息的端點偵聽。這通常是由不正確的地址或SOAP操作引起的。有關更多詳細信息,請參閱InnerException(如果存在)。

內部異常: 「遠程服務器返回錯誤:(404)未找到。」

任何人都可以看到我做錯了什麼嗎?順便說一句,我開始與一個basicHttpsBinding有同樣的問題。

回答

0

解決了它。我試圖在端點地址中使用相對路徑。他們不工作。一旦我將完整的URL放入web.config端點地址中,它就可以工作。

0

您有合同不匹配。

您的服務器已爲此合同進行設置;

contract="Hca.Ims.DataAccess.DataContracts.IImsDataContract" 

您的客戶端的端點是設置爲合同還有

contract="ImsService.IImsDataContract" 

這些都需要相匹配。

+0

ImsService.IImsDataContract是我添加服務引用時在自動生成的代碼中創建的協定的副本。當我運行它時似乎有效。幾乎只要我發佈這個問題,我就找到了我剛發佈的解決方案。不管怎麼說,還是要謝謝你。 – wwarby