Network Security Access Restrictions in Silverlight and Embedded Jetty
Continuing to move forwards with the PoC I’m writing – Java Spring services with HTML(5)/Silverlight RIA. Once I had the main business logic running via Spring, and leverage embedded Jetty, I realised I needed to crossdomain.xml to avoid the Network Security Access Restrictions in Silverlight. The following code solve the problem allow the embedded Jetty to offer up my servlets and also a web folder withe crossdomain.xml file. I’ll drop the RIA code into the web folder as well in the near future.
crossDomainContext = new WebAppContext();
crossDomainContext.setContextPath("/");
File rd = new File("./");
File warPath = new File(rd,"/web");
crossDomainContext.setWar(warPath.getAbsolutePath());
ContextHandlerCollection contexts = new ContextHandlerCollection();
contexts.setHandlers(new org.eclipse.jetty.server.Handler[] { context, crossDomainContext });
server.setHandler(contexts);
So back to the RIA – Silverlight 4. Due to the workflow, the RIA needs to make a REST call to the Java services to get some data, and more important the available end points. Once the client selects certain options, the appropriate end point needs to be subscribed too, allowing data to flow into the RIA. Obviously Rx comes to the rescue here, and specifically Rxx:
var wc = new WebClient();
IObservable<Stream> observable = wc.OpenReadObservable(new Uri("http://localhost:8080/<blah>"));
observable.Subscribe(s => <bah>
I was hoping to also take advantage of the Rx event support for another service I am connected to. Unfortunately this service doesn’t expose the events I am interested in as .NET events. It instead takes in a EventHandler that is called back on as appropriate
