I need to provide a localhost (self hosted) WCF - service for a Silverlight application. This service will provide all kinds of local functionality (legacy stuff, but also access to advanced hardware devices) to the Silverlight application.
Imagine the following situation:
Customer needs to use POS - printers in their native mode, but the application must be a Silverlight one (this is part of the requirement, it can't be discussed and / or changed - and this has very good reasons!).
So I created the clientaccesspolicy.xml and also a crossdomain.xml, but now I found out that so called "cross-zone" - calls are not allowed.
The SL - application will be hosted on a server - farm (which is clearly not in the same zone as "localhost"), while the service itself must absolutely run on localhost.
Is there ANY way to motivate Silverlight to allow me to call a service on localhost from an application that is located on the Internet?
Please take a look on the following VS project:
http://cid-a971dd3af5c625e1.office.live.com/browse.aspx/.Public/SL%5E_DirectPrintingIt was just a silly proof of concept back when SL didn't have printing capability.
Silverlight 4 has printing capability and can also use com interop.
COM interop is Windows only and I believe so is self hosting wcf as it needs full .NET framework installed.
For the self hosting the key is to be able to serve the clientaccesspolicy.xml.
The link contains a zip file with a VS2008 solution.
The compressed file contains 3 projects:
•HostGateway.Win – A Windows forms application that exposes the services for printing and serving the client access policy file. •HostGateway.SL/SL.Web – A simple Silverlight application for testing the whole idea.
Some information on the HostGateway.Win project:
Both services are configured by code only.
And some info on the HostGateway.SL project:
To test the application you should:
If you decide to test this, make sure the win app is running before attempting to talk to it.
If the request for the policy file fails Silverlight will not try again. That means that to get SL to reconnect to the service the SL application has to be restarted.
I hope this helps.
The following links contain info on self hosting:
Link http://www.code-magazine.com/article.aspx?quickid=0701041&page=1