views:

583

answers:

1

I've created a WCF service that is running on 192.168.0.199:87. The service works without a issue. However when I create a silverlight app to consume this service on my dev pc in VS I am getting the crossdomain problem. How am I going to solve this. The service is not a IIS WCF service. I also can't host the WCF service and the silverlight app on the same port. Silverlight is looking for the clientaccesspolicy.xml on 192.178.0.199:87, in this case this is the address of my self hosted WCF service.

Any help would be great.

This is my code I don't now if I brew something good. My app.config file is located here. I think it's a endpoint problem but I am not sure. http://213.46.36.140/app.config.txt



namespace WindowsFormsApplication11
{
    public partial class Form1 : Form
    {
        public ServiceHost _host = null;

        public Form1()
        {
            InitializeComponent();
        }      

        private void button1_Click(object sender, EventArgs e)
        {
            _host = new ServiceHost(typeof(WmsStatService));
            _host.Open();
        }
    }

    // Define a service contract.
    [ServiceContract(Namespace = "http://WindowsFormsApplication11")]
    public interface IWmsStat
    {
        [OperationContract]
        string sayHello(string name);
        [OperationContract, WebGet(UriTemplate = "/clientaccesspolicy.xml")]
        Stream GetSilverlightPolicy();
    }

    public class WmsStatService : IWmsStat
    {
        public string sayHello(string name)
        {
            return "hello there " + name + " nice to meet you!";
        }

        Stream StringToStream(string result)
        {
            WebOperationContext.Current.OutgoingResponse.ContentType = "application/xml";
            return new MemoryStream(Encoding.UTF8.GetBytes(result));
        }
        public Stream GetSilverlightPolicy()
        {
            // result cointains the clienaccpolicy.xml content.
            //
string result = @"

    
        
            
                
            
            
                
            
        
    
";
            return StringToStream(result);
        }
    }
}


A: 

Solved my self. I found some blog posting that helped me very much.

Shift
Would be nice to refer it in your answer.
Dmitry Ornatsky
http://www.darkside.co.za/archive/2009/04/09/consuming-self-hosted-wcf-service-silverlight.aspxhttp://www.netfxharmonics.com/2008/11/Understanding-WCF-Services-in-Silverlight-2#WCFSilverlightConnectivityAsync
Si