1
votes

I have the following operation for hosting my client access policy in my WCF service:

[OperationContract]
[WebGet(UriTemplate = "/clientaccesspolicy.xml")]
XElement RetrieveClientAccessPolicy();

public XElement RetrieveClientAccessPolicy()
{
    String policy = @"<?xml version=""1.0"" encoding=""utf-8""?>
                    <access-policy>
                        ...
                    </access-policy>";

    return XElement.Parse(policy);
}

When I try to connect to my the service from my silverlight app, I get an error because it can't find the client access policy. It's looking for it here:

http://MyServer/clientaccesspolicy.xml

When I browse there in IE, I get a 404. However, I can find the clientaccesspolicy.xml file if I browse to here:

http://MyServer/server/clientaccesspolicy.xml

How can I get my operation to make the client access policy file accessible from the root, and not from that directory (server is the service's name)?

1
Is this for Silverlight 3 or Silverlight 4? The behavior is different depending on the version. Silverlight 3 allows you to host the ClientAccessPolicy file on a dedicated port (which can be a WCF service), which Silverlight 4 does require it to be in the root on port 80.Steve Wranovsky

1 Answers

1
votes

I am guessing that you are not using IIS to host the service since you are trying to return the clientaccesspolicy.xml via a WCF call.

In the case of a self-hosted WCF service, I think you are going to have to set up a separate service endpoint and contract for your RetrieveClientAccessPolicy() call in your App.config. That service would have a baseAddress of http://localhost where your main service would have a base address of http://localhost/server.