locked
Silverlight client on Web Role can't access WCF service in Worker role RRS feed

  • Question

  • Hello,

    I'm getting

    "{System.ServiceModel.CommunicationException: An error occurred while trying to make a request to URI 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. "

    error when my Silverlight application in Web Role tries to access a WCF service hosted in a Worker Role. I attached crossdomain.xml and clientaccesspolicy.xml files to my worker role project which contains WCF service. But still Silverlight client is failing with above error (note that same WCF service can be accessed from a windows console client without any error). Web development helper tool always shows 404 error for both crossdomain.xml and clientaccesspolicy.xml files when client tries to access. 

    Is there any special way to attach cross domain and client access policy files to worker role projects ? Where does Azure keep these files at the runtime ? Looks like Azure doesn't deploy my XML files to ROOT (not sure where this folder is) of WCF service running in Worker role. Note that I'm using Windows Azure SDK 1.2.

    Thanks and regards

    hantaana

     

    Friday, August 13, 2010 5:27 PM

Answers

  • Hi hantana,

    No, WorkerRole still cannot utilize http transport binding element.


    Mog Liang
    • Marked as answer by hantaana Thursday, September 2, 2010 4:13 PM
    Friday, August 20, 2010 3:08 AM

All replies

  • Hi hantaana,

    I assume that you are using netTcpTransport WCF without security setting, because workerRole can only host tcp transport binding, and silverlight doesn't support any seucrity over netTcpTransport.

    For providing crossdomian policy, you need handle the HTTP request on 80 port, and respond with policy xml. An simple way, is using a WebRole working at 80 port and providing crossdomain file. Another possible workaround, is hosting a Tomcat on this workerRole to serve at 80 port, and let it handling crossdomain http request.

    http://code.msdn.microsoft.com/winazuretomcat

    edit: I found that we could host IIS hosted web core in workerRole, it would be another workaround for providing crossdomain file.

    http://code.msdn.microsoft.com/hwcworker

    Thanks,


    Mog Liang
    • Edited by Mog Liang Monday, August 16, 2010 7:52 AM additional information
    • Proposed as answer by Mog Liang Friday, August 20, 2010 10:10 AM
    Monday, August 16, 2010 6:44 AM
  • Hey Mog,

    Thanks for the reply. My WCF endpoint in worker role is using basicHttpBinding. It can be accessed from desktop applications and web applications hosted in web roles in my development environment.

    Is this, accessing basicHttpBinding WCF service endpoint in worker role from outside Azure/ outside worker role, impossible in Azure production environment ?

    Looks like worker role is not capable of responding to crossdomain policy xml HTTP request from Silverlight client. 

    My other option is to expose these WCF endpoints as WCF RIA services to Silvelight client. In this scenario Silverlight client is not interacting worker role. Silverlight client will call a RIA service in the Asp.Net application in Web role and that will call HTTP endpoint in worker role and provide results to the client.

    regards

    Hantaana

     

     

    Monday, August 16, 2010 1:14 PM
  • Hi Hantaana,

    I guess you are testing your cloud application on local dev fabric, in this case, the http transport binding WCF could work at worker role. However, when you deploy the application on windows azure cloud, the worker role doesn't run with administrator priviledge, therefore, the http transport WCF cannot startup successfully.

    As you mentioned that you have a webrole to host silverlight application, then, I suggest you hosting the wcf service on the same webrole, since the wcf and silverlight are in same domain, you need not provide cross-domain policy file anymore.

    Thanks,


    Mog Liang
    Tuesday, August 17, 2010 1:33 AM
  • Hi Mog,

    Do you mean WCF http transport binding is not working on live windows Azure cloud? I've seen this problem in http://social.msdn.microsoft.com/Forums/en/windowsazure/thread/7a767e63-aca7-4ad2-a5c1-afee8cbe041f . Its not still resolved ?

     

    regards

    hantana

    Thursday, August 19, 2010 8:04 PM
  • Hi hantana,

    No, WorkerRole still cannot utilize http transport binding element.


    Mog Liang
    • Marked as answer by hantaana Thursday, September 2, 2010 4:13 PM
    Friday, August 20, 2010 3:08 AM