2013-06-06 31 views
1

我有一個WCF服務URL,如https://crm.xxxx.com/XRMServices/2011/Discovery.svc?wsdl。但是,如果我在瀏覽器窗口中打開這個網址,我會得到一個授權屏幕:Web服務(Discovery.svc?wsdl)和Forefront TMG身份驗證

TMG screenshot

我得到一個異常,如果我嘗試在我的C#代碼添加此網址:

ServiceConfigurationFactory.CreateManagement<T>(new Uri(url)); 

例外:元數據包含無法解析的引用:「https://crm.xxxx.com/XRMServices/2011/Discovery.svc?wsdl」。

例外:元數據包含無法解析的引用: 「https://crm.xxxx.com/XRMServices/2011/Organisation.svc?wsdl」。

如果我有用戶登錄名和密碼,如何從我的客戶端應用程序訪問Web服務?

回答

1

TMG基本上是一個公司防火牆,阻止您的傳入請求,所以您首先必須與TMG進行協商,然後將您的請求發送給您的WCF服務。

下面是一個簡單結合我從the following MSDN blog entry了處理類似的問題:

<system.serviceModel> 
    <bindings> 
     <basicHttpBinding> 
      <binding name="BasicHttpBinding_IService1"> 
       <security mode="Transport"> 
        <transport clientCredentialType="Certificate" /> 
        </security> 
      </binding> 
     </basicHttpBinding> 
    </bindings> 
    <client> 
     <endpoint address="https://www.myservice.com/Service1.svc" 
        behaviorConfiguration="myEndpointBehaviour" 
        binding="basicHttpBinding" 
        bindingConfiguration="BasicHttpBinding_IService1" 
        contract="Client.IService1" 
        name="BasicHttpBinding_IService1" /> 
    </client> 
    <behaviors> 
     <endpointBehaviors> 
      <behavior name="myEndpointBehaviour"> 
       <clientCredentials> 
        <clientCertificate 
         storeName="My" 
         storeLocation="CurrentUser" 
         findValue="CN=WCF client cert 2" /> 
       </clientCredentials> 
      </behavior> 
     </endpointBehaviors> 
    </behaviors> 
</system.serviceModel> 

這種結合,如果你的服務沒有任何消息級安全啓用將已經這樣做了。

順便說一句,請確保您有訪問該服務的正確證書,登錄名和密碼可能意味着消息級別的安全性。