Source: ArcGIS API for Silverlight call WebService a workaround for cross-domain access errors
Several friends in the group mentioned the problem, saying that they called the WebService method in Silverlight, and reported the error in the following map:
Workaround:
1. Make sure that your Silverlight project and the Web program hosting Silverlight contain 2 cross-domain files, namely crossdomain.xml and ClientAccessPolicy.xml, in the root directory:
crossdomain.xml file, as follows:
<?xml version= "1.0"?> <cross-domain-policy> <allow-access-from domain= "*"/></ Cross-domain-policy>
ClientAccessPolicy.xmlFile, as follows:
<?xml version= "1.0" encoding= "Utf-8"?><access-policy> <cross-domain-access> <policy > <allow-from> <domain uri= "*"/> </allow-from> <grant-to> < Resource Path= "/" include-subpaths= "true"/> </grant-to> </policy> </ Cross-domain-access></access-policy>
2. When adding a Web service reference in Silverlight, do not use a similar http://localhost:90801/XXX/with VS Xxx.asmx address, deploy a Silverlight-hosted Web program to IIS, and then add a Web service reference, with an address similar to Http://localhost/XXX/YYY/xxx.asmx, if your webservice is correct. The next step is important, open the reference after the completion of the service reference configuration file, if the service address is local, please remove the address of the application name in front of the symbol, such as:
After the processing of the above steps, the debug run program will not appear cross-domain error prompts, write out, so that later people encounter this problem can be less detours.
Workaround for the ArcGIS API for Silverlight call WebService cross-domain access error