Service Unavailable when asking for clientaccesspolicy.xml Composite WebRole in Azure - silverlight

I'm using the Composite WebRole approach to host 2 web apps in the same instance and webrole in Azure, one app is using Silverlight and needs to get (for many reasons) the clientaccesspolicy.xml from the root domain which is mydomain.cloudapp.net so it returns Service is unavailable error as expected.
Is there a way to catch the clientaccesspolicy.xml request and redirect it to my custom domain where my clientaccesspolicy file is available? or how can I enable my cloudapp.net domain using this approach? thanks

Working with the Root Container
Enabling Cross-Domain Access to Blobs

Related

Communication Exception while calling .asmx service from silverlight

I have a .asmx web service which is hosted on IIS. I took the service reference and i am calling this web service from my silverlight application. But i am getting a communication exception as follows.
An error occurred while trying to make
a request to URI
'http://test.bookmyshow.com/services/wsDebtorTrans.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.
I have added the required policy files (clientaccesspolicy.xml and crossdomain.xml) to my web service. Following is the content of my clientaccesspolicy.xml and crossdomain.xml
crossdomain.xml and clientaccesspolicy
I tried to access the above two files from my browser and the xml files are displayed properly in my browser. I have used basicHttpBinding. I have seen lot of tutorials online and tried them but still I am facing the same problem. Am I missing anything here? Please help me with this problem.
Just to clarify, you only need a CrossDomain.xml file OR a ClientAccessPolicy.xml file. You don't need both. Also, where did you put those files? Did you put it in the Services folder, or did you put it in the root of the server? For example, http://test.bookmyshow.com/ClientAccessPolicy.xml instead of http://test.bookmyshow.com/Services/ClientAccessPolicy.xml . The file should be put in the Root of your application and not the Services folder.

When and how to use clientaccesspolicy.xml in Silverlight

I am confused by when and how to use the clientaccesspolicy.xml file in Silverlight. What is it for? Right now, my deployed site (not localhost but the remote server) does NOT have it and I can still access the web site and query the database through a WCF web service. Why should I include it in my root directory?
You only need it if your Silverlight app will be accessing a service in another domain.
e.g (from the MS site)
"For example, a Silverlight control hosted at http://contoso.com/mycontrol.aspx can access only services on that same domain by default – for example http://contoso.com/service.svc, but not a service at http://fabrikam.com/service.svc."
When your silverlight application try to access the method of web service.
For the security silverlight first identify the service is valid one not the fake.
For that silverlight first request the "ClientAccessPolicy.xml" file, then requested web service will returns the xml file after that silverlight checks that application is allowed to accept call from current service..if yes then app can free to make a service call to verified service.

cross-domain policy error in Silverlight with WCF

I'm getting the following error when I connect my Silverlight app to my WCF service. I host this wcf as a self host service.
An error occurred while trying to make a request to URI 'http://lmr-hero/iSponsorWebSite/projectService.svc/basic'. 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.
What are the possible reasons for this error?
If your Silverlight application is not hosted on the same domain as the service then you will need to put a clientaccesspolicy.xml or crossdomain.xml file on the server that hosts the service.
See this link for details: http://msdn.microsoft.com/en-us/library/cc197955%28VS.95%29.aspx
Right click the .svc file and hit view in browser. Check to see if it's even being hosted and running correctly first. That will give you a good starting place.
Be careful that you set up a WCF web service correctly in Silverlight, when using Silverlight to consume the web service. Unlike a console mode client, in Silverlight you cannot just create a WCF New Item in your Solution, but must, under the .Web portion of your Silverlight solution, right-click, Add a New Item that is called "Silverlight-enabled WCF Service". Now you can go to the Silverlight app folder, add a Service Reference and you will not get this run-time error. This will avoid the run-time error the original poster refers to.

cross-domain problem

I am using a silverlight with wcf and when I use the .web project then it runs but when use the silver light project to run the following exception throws:
An error occurred while trying to make a request to URI 'http://localhost:9000/Services/BLWCFSvrc.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.
I want to use the silverlight project to debug my code
Thanks in advance
In order to access network resources from Silverlight, the domain hosting the resource must provide a client access policy file; this is designed this way for security reasons. See here for details: http://msdn.microsoft.com/en-us/library/cc645032%28VS.95%29.aspx
I think your problem is different that just having the clientaccesspolicy.xml, the fact that it runs under the web project, means that you are delivering policies, if you have those added as seperate files under the web project then they wont be deployed when you run the SL3 app seperately, but im sure you figured this out and you're delivering the policies via WCF using webHttp binding (RESTful style), if not, you should.
I think the problem is that when you run the webproject, it builds to your local IIS and executes from there, IIS will allow the SL3 app to communicate with ports/addresses different from the ones that the site is hosted on
when you run SL3 app natively, VS2008 auto generates a test html site for it to be hosted in with some default settings, and uses VS2008 built-in hosting service, which does not allow communication to an address/port different from that of the hosting address. (even though Silverlight is a client side library, VS2008 can do this)
so if you want to run the Silverlight application natively, meaning actually executing the XAP, you can deploy it to IIS, and configure IIS to deliver XAP files, or just install it and run it out of browser and let it update from IIS the deployed version
Just copy a clientaccesspolicy.xml file (for an example take a look at this post; you can even use this sample) into the root of your webserver (eg: c:\inetpub\wwwroot\).
This should help.

Silverlight Cross Domain Policies

In a silverlight application, I want to access the page the silverlight .xap file from an HTTP subdomain, but have the web services access a different subdomain for sensitive information over HTTPS.
I set up clientaccesspolicy.xml at the root of the subdomain and it lets the silverlight app access its services over http, but not over https. It gives the cross domain access error that it would give normally without a clientaccesspolicy in place.
I know that browsers themselves have a lot of restrictions about mixing http and https. Am I trying to do something that is not allowed?
Check out:http://silverlight.net/forums/t/12741.aspx
You can either make https calls to the
same domain or http cross-domain
calls, but not https cross-domain
calls.
This is described in
http://msdn2.microsoft.com/en-us/library/cc189008(VS.95).aspx
(see "If not HTTPS" in the matrix)
By JohnSpurlock
This is out of date since Silverlight 2.0 was released. You can now do most cross-domain scenarios with the appropriate configuration. http://msdn.microsoft.com/en-us/library/cc197955(VS.95).aspx
The important thing to note here that is not in the above information clearly is you must have access to the "ROOT" level of the domain request, and the clientaccesspolicy.xml must reside at that level.
If for example you have a production environment that your application is behind a load balancer that directs traffic as most large companies do to your application via the URI, you then have a little bit of a problem.
Example: http://mydomain.com/MyApplication/* goes to your server, where your app resides.
http://mydomain.com/clientaccesspolicy.xml is where the policy exists.

Resources