开发者

Wcf configuration for Silverlight

In my silve开发者_运维百科rlight app I use service reference to wcf service. After I deployed this project to my test IIS, I couldn't see any .config file where all endpoint information is stored. That ServiceReferences.ClientConfig is packed in xap package. How would I deploy it to customer's server then? I need a way to configure endpoint there. How do you do that?


Instead of trying to support editing the clientconfig file in the XAP, here is another approach.

Add the web service endpoint address to the Silverlight InitParams in the HTML page that host the Silverlight application. Maybe set the initparams dynamically via ASP.NET. Programatically use this address when creating the client-side service proxy.

Another option is to assume the web service is always in a relative directory to the hosting page. I used something like:

new Uri(HtmlPage.Document.DocumentUri, new Uri("./MyService/MyService.svc", UriKind.Relative)); 

Combining both options works well, if the InitParams are missing, I use a the relative path to the well known location (helpful in deployment/production). If the IntiParams have a endpoint, I use that (helpful in debugging/testing).


If you mean configure the endpoint after the application has been published then there is no way to do it easily (you could unzip the xap, change the ServiceReferences.ClientConfig, rezip ...)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜