1

我有一個webservice和一個Silverlight應用程序。 我也具有crossdomain.xml和clientaccesspolicy.xmlSilverlight 4.0:跨域策略錯誤

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

這裏我跨域策略

<?xml version="1.0"?> 
<!DOCTYPE cross-domain-policy 
    SYSTEM "http://www.macromedia.com/xml/dtds/cross-domain-policy.dtd"> 
<cross-domain-policy> 
    <allow-access-from domain="http://localhost/MHVWS/MachineHistoryWS.asmx" /> 
</cross-domain-policy> 

我的Web服務在IIS中被託管。

有了這個配置我仍然有這樣那樣的錯誤:

An error occurred while trying to make a request to URI 'http://localhost/MHVWS/MachineHistoryWS.asmx'. 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.

請幫

回答

0
  • 你只需要一個政策文件。你不需要兩個。
  • 確保這些策略文件中的一個(或兩個)與web服務存在於相同的位置(域)中。
  • 要調試並查看正在發生的事情,請使用Fiddler這樣的工具來驗證客戶端正在查找的策略xml文件的url路徑。