Navigation


Milos Solution Platform (External Blog)

The Milos Solution Platform is .NET's premier platform for building business applications. This blog is meant for developers who use or evaluate Milos. This blog is used to share tidbits of information provided by the Milos developers at EPS. Many of the posts put the spotlight on new features. We generally recommend that all Milos users (developers) at least scan this blog to keep up with the Milos news.

Content Area Footer

Sunday, February 08, 2009
Self-Hosted WCF Cross-Domain Service Call Policies

Yesterday I blogged about a new Milos feature that allows to self-host Basic HTTP services, which is a feature that is useful when one has a service that is hosted using other bindings, but wants to expose the Basic HTTP binding in addition to others, which is typically done in Silverlight or browser scenarios (click here for yesterday's post).

When hosting Basic HTTP services for Silverlight, it is also important to know that Silverlight by default can only call services that are part of the same web application as the Silverlight app itself. This will practically never be the case when you self -host a Basic HTTP service. To allow that service to be called from Silverlight, the service must opt in to be callable across domains. (Note: Different ports also count as different domains in this case). This is a security restriction to avoid cross-site attacks.

Using the Milos self-host Basic HTTP feature, you can also enable cross-domain calling like so:

ServiceGarden.AllowCrossDomainCalls();

For instance, if you want to host a service that is available both over TCP/IP and Basic HTTP and allows cross-domain calls, it could be done like so:

ServiceGarden.AllowCrossDomainCalls();
ServiceGarden.AddServiceHostNetTcp(typeof(EventService));
ServiceGarden.AddServiceHostBasicHttp(typeof(EventService));

Note that the cross-domain call only relates to HTTP based access, but not to other protocols.

Note also that the cross-domain call is enabled by means of a policy that is now available. You can browse to that policy using your web browser. For instance, if you run this in a test environment on localhost, you can now browse to http://localhost/clientaccesspolicy.xml, to see the exact settings that are exposed. This is what Silverlight accesses to allow a cross-domain call.

Note that it is possible to set additional parameters. In particular, you can specify which sites can make a cross domain call. For instance, if you only want to accept calls from www.Microsoft.com and www.Google.com, you can restrict the cross domain calls in the following fashion:

ServiceGarden.AllowCrossDomainCalls(new Uri[] {
    new Uri("http://www.Microsoft.com"),
    new Uri("http://www.Google.com") });

Note that these features are available on the ServiceGarden class as well as the development host. When the development host is used, the policy is listed in the UI as an additional service endpoint.

 

Posted @ 1:40 PM by Egger, Markus (markus@code-magazine.com) -
Comments (12)


Saturday, February 07, 2009
Self-Hosting Basic HTTP WCF Services

Milos provides a real simple way to develop and host (both in runtime as well as debug scenarios) WCF services. This is especially true for binary, TCP/IP based services that are great to use when both the client and the server are .NET applications. Another common scenario is hosting WCF services as HTTP and XML based web services. Especially with Silverlight, basic HTTP based services have gained more importance again. Of course, it is simple to host such services in IIS, and thus we have not provided any special features around that in Milos.

At least not so far. One of the scenarios people have pointed out to us (and frankly, we've run into ourselves too) is a deployment of the same service using multiple bindings. Why deploy one app for TCP/IP and then create a separate, ASP.NET based web app for XML web service support?

We have now created support for Milos aided, self-hosted Basic HTTP services. This is supported both in the ServiceGarden and development host environments. Here is an example of hosting a service in both TCP/IP and Basic HTTP configurations at the same time:

ServiceGarden.AddServiceHostNetTcp(typeof(EventService));
ServiceGarden.AddServiceHostBasicHttp(typeof(EventService));

This example was from a runtime deployed service (likely hosted in a Windows Service). The following example shows the same service hosted in the development environment with support for both protocols.

var host = new TestServiceHost();
host.AddNetTcpService(
typeof(EventService
));
host.AddBasicHttpService(
typeof(EventService));

Accordingly, the ServiceClient class can now also natively open a connection to a Basic HTTP driven service. (Application configuration now supports "BasicHttp" as an additional service binding).

Enjoy!



Posted @ 4:46 PM by Egger, Markus (markus@code-magazine.com) -
Comments (12)


 

 

 

 

 

 

 

Syndication RSS 2.0 RSS 2.0

All My Blogs:
My personal blogs:
Dev and Publishing Dev and Publishing
Travel and Internat. Living Travel and Internat. Living
Other blogs I contribute to:
Milos Blog (US) Milos Blog (US)
VFPConv. Dev Blog (US) VFPConv. Dev Blog (US)
VFPConv. Dev Blog (DE) VFPConv. Dev Blog (DE)

 

Blog Archives
All Blog Posts

2010
    November (1)
2009
    July (2)
    February (2)
    January (1)
2008
    December (1)
    October (3)
    June (1)
    April (3)
    February (1)
    January (1)
2007
    December (1)
    October (2)
    September (2)
    July (1)
    June (2)
    May (4)
    April (6)
    March (8)
    February (3)
    January (2)
2006
    December (2)
    November (2)

 

 

 

This Blog is powered by MilosTM Collaboration Components.