I've got a wierd problem. I have an IIS website that hosts my webservice calls for another website. The dns names are ws.<domainname> and
www.<domainname>. As far as I can tell, both the silverlight control and the wcf service work. I can wire up a local web that hosts my control that references the external web service and the silverlight control works.
I can create silverlight controls that do not access wcf web services and they work. Whenever I try to create a silverlight control that accesses wcf services, I get:
An error occurred while trying to make a request to URI 'http://ws.<domainname/service>.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. Please see the inner exception for more details.
I have both a clientaccesspolicy.xml and a crossdomain.xml which are wide open.
I can get to the ws service and wsdl on the services site.
I've run the Nikhil's web tool and get all 200 OKs on this
I've been struggling with the same problem, but suddenly discovered a seemingly odd and annoyingly simple suggestion, which worked for me. You mention you have BOTH a clientaccesspolicy.xml and a crossdomain.xml file? Try deleting clientaccesspolicy.xml
so you are left with ONLY crossdomain.xml. Did the error then magically dissapear?
As suggested by Ken, you should also verify the web.config configuration file of your service, the binding must be set as "basicHttpBinding" instead of "wsHttpBinding":
This suggestion of removing the clientaccesspolicy.xml, leaving only the crossdomain.xml worked a treat for me. Thank you! - if only I had tried this out two days ago I'd have more of my hair left.
In my particular instance of the problem I had a seperate local domain name for the wcf web service (api.dev) and the web site (web.dev) which I had set up via the \WINDOWS\system32\drivers\etc\hosts file and setting the appropriate host header value in
IIS 6.0 (Windows Server 2003).
What was interesting was that the clientaccesspolicy.xml worked fine for me if the domain names were single words eg. wcf service domain name = "api" and web site domain name = "web" ... or just "localhost" which is used in most of the examples, but obviously
this is no good for a production release. So when I changed the domain names (and updated all the relevant references, etc) I was suprised to find that the silverlight component was throwing the "cross domain access error".
Another interesting point was that when I tried using fiddler to examine the http traffic there were no requests for either of the .xml files .. this did not make sense to me, why would I not see the request in fiddler or web developer helper? I get the
feeling that there were probably a number of contributing factors, but I'm just not entirely sure what they were.
Hope this helps someone else.
Silverlight & WCF Service issueWCF Silverlight IISwcf silverlightAccessing Services
devwheel
Member
4 Points
7 Posts
Another Cross Domain Issue
Dec 27, 2008 01:14 AM | LINK
I've got a wierd problem. I have an IIS website that hosts my webservice calls for another website. The dns names are ws.<domainname> and www.<domainname>. As far as I can tell, both the silverlight control and the wcf service work. I can wire up a local web that hosts my control that references the external web service and the silverlight control works. I can create silverlight controls that do not access wcf web services and they work. Whenever I try to create a silverlight control that accesses wcf services, I get:
An error occurred while trying to make a request to URI 'http://ws.<domainname/service>.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. Please see the inner exception for more details.
I'm out of ideas how to get this working.
Silverlight & WCF Service issue
Ken Tucker
All-Star
23246 Points
3532 Posts
Re: Another Cross Domain Issue
Dec 27, 2008 10:13 AM | LINK
Is the wcf service you are trying to access using basicHttp binding?
Space Coast .Net User Group
devwheel
Member
4 Points
7 Posts
Re: Another Cross Domain Issue
Dec 27, 2008 05:11 PM | LINK
Yes, doing it in code.
void SetWS()
{
BasicHttpBinding binding = new BasicHttpBinding();
EndpointAddress address = new EndpointAddress("http://ws.DNSNAME/ServiceName.svc");
MyService.MyServiceClient proxy = new PhotoRotator.MyService.MyServiceClient(binding, address);
proxy.GetMyServiceCompleted += proxy_GetMyServiceCompleted;
proxy.GetMyServiceAsync();
}
thehoonmeister
Member
6 Points
8 Posts
Re: Another Cross Domain Issue
Jan 02, 2009 02:11 PM | LINK
I've been struggling with the same problem, but suddenly discovered a seemingly odd and annoyingly simple suggestion, which worked for me. You mention you have BOTH a clientaccesspolicy.xml and a crossdomain.xml file? Try deleting clientaccesspolicy.xml so you are left with ONLY crossdomain.xml. Did the error then magically dissapear?
Rich.
davidezordan
Contributor
6294 Points
957 Posts
Re: Re: Another Cross Domain Issue
Jan 02, 2009 02:20 PM | LINK
Hi devwheel,
the client code is ok.
As suggested by Ken, you should also verify the web.config configuration file of your service, the binding must be set as "basicHttpBinding" instead of "wsHttpBinding":
<
endpoint address="" binding="basicHttpBinding" contract="YourNameSpace.YourService" />Silverlight MVP
Blog Twitter Silverlight Experts
diffident
Member
10 Points
27 Posts
Re: Another Cross Domain Issue
Jan 02, 2009 06:20 PM | LINK
Hi Rich,
Thanks for your suggestion! What I did was, I deleted crossdomain.xml instead of clientaccesspolicy.xml and the error dissappeared magically!
I spent hours and hours rewriting, regenerating the code and it boils down to this intriguing solution.
Thanks again
devwheel
Member
4 Points
7 Posts
Re: Re: Re: Another Cross Domain Issue
Jan 08, 2009 12:43 AM | LINK
Yes the service is marked in the web.config as basic
brodie
Member
24 Points
2 Posts
Re: Another Cross Domain Issue
Jan 13, 2009 04:04 AM | LINK
This suggestion of removing the clientaccesspolicy.xml, leaving only the crossdomain.xml worked a treat for me. Thank you! - if only I had tried this out two days ago I'd have more of my hair left.
In my particular instance of the problem I had a seperate local domain name for the wcf web service (api.dev) and the web site (web.dev) which I had set up via the \WINDOWS\system32\drivers\etc\hosts file and setting the appropriate host header value in IIS 6.0 (Windows Server 2003).
What was interesting was that the clientaccesspolicy.xml worked fine for me if the domain names were single words eg. wcf service domain name = "api" and web site domain name = "web" ... or just "localhost" which is used in most of the examples, but obviously this is no good for a production release. So when I changed the domain names (and updated all the relevant references, etc) I was suprised to find that the silverlight component was throwing the "cross domain access error".
Another interesting point was that when I tried using fiddler to examine the http traffic there were no requests for either of the .xml files .. this did not make sense to me, why would I not see the request in fiddler or web developer helper? I get the feeling that there were probably a number of contributing factors, but I'm just not entirely sure what they were.
Hope this helps someone else.
Silverlight & WCF Service issue WCF Silverlight IIS wcf silverlight Accessing Services
Endurance Man
Member
8 Points
12 Posts
Re: Re: Another Cross Domain Issue
Jan 23, 2009 01:05 PM | LINK
Deleting the second policy worked a charm! Nice one whoever suggested it :)
thehoonmeister
Member
6 Points
8 Posts
Re: Re: Another Cross Domain Issue
Jan 23, 2009 01:45 PM | LINK
Thanks, you're welcome! It's nice to come up with a solution for once, I usually just troll around these forums and contribute nothing [:D]