Share via


WCF: REST WCF Integration with HTML 5 and Windows 8 Store Applications

Issue:

I happen to work with this customer where they required to consume the REST WCF service hosted on IIS and windows service via HTML 5 and Windows 8 store application.

 

Problem :

To get the HTML 5 and windows store 8 app connect to REST WCF, we need to use the AJAX to write the code. When I started working on this I faced this strange problem….

 

The application throws a 405 Error

When I enabled WCF tracing I found this….

 

To Handle the behavior:

Client Code:

 

In WCF config file:

 

 

 Observations:

This thing works till the time my WCF is running on IIS, if I host the same service as windows service, I again start getting error.

Error when I hosted the same WCF service as Windows Service

 

 Reason:

The main reason for the error is because of the fact that the above <system.webServer> tag is only read by IIS hosting environment, not by windows service hosting.

 

Solution:

Modify the WCF method like this…

Which will handle the incoming OPTION attribute inside the header.

 

 

 Some references on cross domain concept:

 Hope this info help in getting started on creating WCF REST service consumable by the HTML5 and Windows 8 Store applications.