Thursday, August 16, 2012

Using JsonServiceClient in OOB Silverlight application

Using JsonServiceClient in OOB Silverlight application

Is it possible to use JsonServiceClient in Silverlight when running OOB (Out of browser)?

I have a backend system which expose a number of webservices using ServiceStack, and i would like to use ServiceStack on the client-side of the system also.

I am developing the client in Silverlight 5. When i test the client running inside a browser the JsonServiceClient works as expexted - but when running OOB (a requirement) it throws a exception stating "The DOM/scripting bridge is disabled." - which occurs because when running OOB you do not have access to the browser API - but are there any workaround?

The code which works in browser, but casts exception OOB:

var restClient = new JsonServiceClient("http://127.0.0.1:1030"); restClient.GetAsync<AgentModelResponse>("/agents",   r =>   {     r.Agents.ForEach(x => Agents.Add(x));   },   (r, ex) =>   {     throw ex;   }); 

Answers & Comments...

Answer: 1

You need to host and access your web service using SSL, in order for web service calls to work in an OOB Silverlight app.

http://msdn.microsoft.com/en-us/library/dd550721(VS.96).aspx

Answer by Ivan Karajas for Using JsonServiceClient in OOB Silverlight application




No comments:

Post a Comment

Send us your comment related to the topic mentioned on the blog