2010-06-10 86 views
0

我有一個SL3應用程序試圖連接到一個WFC服務。應用程序和服務都位於同一個域中的不同安全服務器上。該SL3應用程序住在這裏:的Silverlight 3與WCF服務 -

https://www-r.aetc.af.mil/fm/tools/batsnet/authenticated/modules/blah等等

當SL應用程序啓動時,它立即連接到服務,但是當它使得它的第一個電話到服務,我得到這個異常:

An exception occurred during the operation, making the result invalid. Check InnerException for exception details. 
    at System.ComponentModel.AsyncCompletedEventArgs.RaiseExceptionIfNecessary() 
    at FMDashboard2.FMDashSvc3Ref.GetMetricDataCompletedEventArgs.get_Result() 
    at FMDashboard2.Objects.DataRetrieval.service_GetMetricDataCompleted(Object sender, GetMetricDataCompletedEventArgs e) 
============ 
Inner exception: An error occurred while trying to make a request to URI 'https://bats.aetc.af.mil/fm/tools/FMDashSvc/FMDash3.svc'. This could be due to attempting to access a service in a cross-domain way without a proper cross-domain policy in place, or a policy that is unsuitable for SOAP services. You may need to contact the owner of the service to publish a cross-domain policy file and to ensure it allows SOAP-related HTTP headers to be sent. This error may also be caused by using internal types in the web service proxy without using the InternalsVisibleToAttribute attribute. Please see the inner exception for more details. 
    at System.ServiceModel.AsyncResult.End[TAsyncResult](IAsyncResult result) 
    at System.ServiceModel.Channels.ServiceChannel.SendAsyncResult.End(SendAsyncResult result) 
    at System.ServiceModel.Channels.ServiceChannel.EndCall(String action, Object[] outs, IAsyncResult result) 
    at System.ServiceModel.ClientBase`1.ChannelBase`1.EndInvoke(String methodName, Object[] args, IAsyncResult result) 
    at FMDashboard2.FMDashSvc3Ref.FMDash3Client.FMDash3ClientChannel.EndGetMetricData(IAsyncResult result) 
    at FMDashboard2.FMDashSvc3Ref.FMDash3Client.FMDashboard2.FMDashSvc3Ref.FMDash3.EndGetMetricData(IAsyncResult result) 
    at FMDashboard2.FMDashSvc3Ref.FMDash3Client.OnEndGetMetricData(IAsyncResult result) 
    at System.ServiceModel.ClientBase`1.OnAsyncCallCompleted(IAsyncResult result) 
============ 
Inner exception: 
    at System.Net.Browser.AsyncHelper.BeginOnUI(SendOrPostCallback beginMethod, Object state) 
    at System.Net.Browser.BrowserHttpWebRequest.EndGetResponse(IAsyncResult asyncResult) 
    at System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelAsyncRequest.CompleteGetResponse(IAsyncResult result) 
============ 
Inner exception: Security error. 
    at System.Net.Browser.BrowserHttpWebRequest.InternalEndGetResponse(IAsyncResult asyncResult) 
    at System.Net.Browser.BrowserHttpWebRequest.c__DisplayClass5.b__4(Object sendState) 
    at System.Net.Browser.AsyncHelper.c__DisplayClass2.b__0(Object sendState)

這裏是我的ClientConfig:

<configuration> 
    <system.serviceModel> 
     <bindings> 
      <customBinding> 
       <binding name="SecureBinding_FMDashSvc"> 
        <binaryMessageEncoding /> 
        <httpsTransport maxReceivedMessageSize="2147483647" maxBufferSize="2147483647" /> 
       </binding> 
       <binding name="LocalBinding_FMDashSvc"> 
        <binaryMessageEncoding /> 
        <httpTransport maxReceivedMessageSize="2147483647" maxBufferSize="2147483647" /> 
       </binding> 
      </customBinding> 
     </bindings> 

     <client> 
      <endpoint address="https://bats.aetc.af.mil/fm/tools/FMDashSvc/FMDash3.svc" 
         binding="customBinding" 
         bindingConfiguration="SecureBinding_FMDashSvc" 
         contract="FMDashSvc3Ref.FMDash3" 
         name="SecureEndPoint_FMDashSvc_GDIT_BATS" /> 
      <endpoint address="http://localhost:53519/FMDash3.svc" 
         binding="customBinding" 
         bindingConfiguration="LocalBinding_FMDashSvc" 
         contract="FMDashSvc3Ref.FMDash3" 
         name="LocalEndPoint_FMDashSvc" /> 
     </client> 
    </system.serviceModel> 
</configuration>

這裏是我的服務網絡配置:

<system.serviceModel> 
    <behaviors> 
     <serviceBehaviors> 
      <behavior name="FMDashboardSvc3.StandardBehavior" > 
       <serviceMetadata httpsGetEnabled="true" /> 
       <serviceDebug includeExceptionDetailInFaults="true" /> 
      </behavior> 
     </serviceBehaviors> 
    </behaviors> 

    <bindings> 
     <wsHttpBinding > 
      <binding name="secureBinding"> 
       <security mode="Transport"> 
        <transport clientCredentialType="Certificate" /> 
       </security> 
      </binding> 
     </wsHttpBinding> 
    </bindings> 

    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" /> 

    <services > 
     <service name="FMDashboardSvc3.FMDash3" behaviorConfiguration="FMDashboardSvc3.StandardBehavior"> 
      <endpoint address="/" 
         binding="wsHttpBinding" 
         bindingConfiguration="secureBinding" 
         contract="FMDashboardSvc3.FMDash3" /> 
     </service> 
    </services> 
</system.serviceModel> 

這是我的ClientAccessPolicy.xml文件:

<?xml version="1.0" encoding="utf-8" ?> 
<access-policy> 
    <cross-domain-access> 
     <policy> 
      <allow-from http-request-headers="SOAPAction"> 
       <domain uri ="http://*" /> 
       <domain uri ="https://*" /> 
      </allow-from> 
      <grant-to> 
       <resource path="/" include-subpaths="true"/> 
      </grant-to> 
     </policy> 

     <policy> 
      <allow-from https-request-headers="SOAPAction"> 
       <domain uri ="http://*" /> 
       <domain uri ="https://*" /> 
      </allow-from> 
      <grant-to> 
       <resource path="/" include-subpaths="true"/> 
      </grant-to> 
     </policy> 
    </cross-domain-access> 
</access-policy> 

我一直工作在這幾個星期。我錘擊Codeproject和MSDN論壇,沒有人能夠爲我提供解決方案。幫助我,obi-wan-kenobi。

+0

是否使用自簽名的證書或實際證書? – 2010-06-10 19:34:39

+0

我相信他們是真正的證書。這是一個空軍域,他們使用CAC卡進行用戶身份驗證。 – jsop 2010-06-11 11:33:53

+0

順便說一句,我沒有提到它,但我可以直接瀏覽到服務,但通過Silverlight應用程序擊中它拒絕工作。 – jsop 2010-06-11 11:57:19

回答

0

我認爲這個問題可能與服務器端的clientCredentialType有關。例如:

<security mode="Transport"> 
    <transport clientCredentialType="Certificate" /> 
</security> 

我不認爲Silverlight支持傳輸級的這種客戶端憑證。

+0

好吧,如果我將其更改爲任何其他憑證類型,我無法直接瀏覽到該服務。 – jsop 2010-06-11 11:56:03

0

您將您的服務公開爲Silverlight不支持的Ws綁定。如果你用basicHttpBinding使用相同的安全設置,它應該可以工作。