Self hosted WCF SOAP Cors preflight - wcf

How to handle Cors preflight in self hosted WCF soap service? Most examples I have seen are related to WCF Rest or IIS hosted or simple Cors.

I realize that your luking for an answer of .NET solution, on the other hand, this might be giving an idea of solution for you.
https://docs.oracle.com/cd/E13222_01/wls/docs103/webserv_adv/handlers.html
Here in SOAPHandler section, when it is an "OutBoundMessage", then you should add CORS headers to avoid getting security error from browser.

Related

WCF CORS issue - WPF application successfully connects but Angular App throws 405

I have a question about enabling cross-domain calls.
I have a WCF Rest service that is hosted in xyz domain. I am able to test these REST APIs from Advanced Rest Client, Postman and Fiddler. I also have a WPF application that actively calls these API which is hosted in a different domain (say abc domain) which works fine in getting responses.
However, when I created a new Angular web application and a Windows Service (deployed on abc domain), and tried calling the APIs from these two components, I am getting a 405 error.
Can someone explain:
How REST clients always are able to successfully establish a connection?
How does my WPF successfully connects to the WCF service even though
its on a different domain?
Why is my Windows Service/Web App not able to talk to WCF?
I assume that the issue here is caused by the preflight request. The browser issues this OPTIONS verb request to ask the server if the origin is allowed to call the API in a non-safe manner.
If your WCF REST service does not deal with this request, the WCF runtime will try to dispatch the request to your service implementation.
However, if the runtime does not find a method to call for this verb, it will return a 405 Method Not Allowed response.
I've dealt with this in the past by using an IOperationInvoker implementation, installed via an IOperationBehavior. This article describes a slightly different way of doing basically the same.

Application Request Routing use with WCF Restful web services

Anybody done with the Application Request Routing use with WCF Restful web services?
The requirement is, from the mobile application, invokes webservices URLs. But the reverse proxy needs to route the request to actual server. Can anybody suggest a soultion?
Finally I have solved it. Please refer the following link for further reference.
http://blogs.iis.net/carlosag/archive/2010/04/01/setting-up-a-reverse-proxy-using-iis-url-rewrite-and-arr.aspx

Does the WCF Data Services Toolkit support CORS out of the box?

I'm trying to find a decent solution for cross-domain connections between WCF Data Services and datajs. JSONP works great for GET requests, but I can't POST anything. Does the WCF Data Services Toolkit support CORS out of the box? Are there any resources out there that show how to implement CORS for WCF Data Services?
WCF DS does not support CORS out of the box. I haven't been able to find any other out of the box solutions. It may be possible to add CORS support to a server by creating a message inspector for WCF.

Using WCF to create a RESTful Web Service that requires authentication and uses JSON as input/output format

I want to port an existing ASP.NET Web Service to WCF so the resulting Web Service (1) is RESTful, (2) uses JSON as its request/response format, (3) has a custom authentication mechanism.
After a lot of googling, random coding, and wanting to hit my head against the wall, I found that...
A webHttpBinding has to be used to make the Web Service RESTful. But...
webHttpBinding does not support HTTPS hosts.
webHttpBinding does not support UserName authentication.
webHttpBinding does not even support message security.
An endpoint behavior with <enableWebScript/> has to be used to support ASP.NET AJAX. But...
What is "ASP.NET" AJAX?
What if I want to consume the Web Service using "regular" AJAX?
And, most importantly...
Can WCF do what I want to do in first place?
If not, what other platforms could I use?
I've written WCF service that does both SOAP and REST with XML and JSON, and custom auth. I've pushed the custom authentication into HTTP module, which does basic auth over https. See Custom HTTP Basic Authentication for ASP.NET Web Services on .NET 3.5/VS 2008 and WCF POX, JSON and SOAP Coexist.
In the setup you describe, the web servier (i.e. IIS) will be responsible for encryption (HTTPS) and authentication (e.g. basic authentiction). IIS can be extended with a custom authentication mechanism (just google for "IIS module handler").
It's a bit strange that it has to be delegated to IIS and is not part of WCF. But it's no problem at all.

WCF BasicHttpBinding Http Post

Is it possible to post to a WCF service hosted in IIS? I know that that this is possible using REST but I really need the WSDL generation and SOAP headers. I need to transition an existing ASMX web services to WCF but I need to also allow my clients to continue to utilize the service via http posts (xml http request via javascript). Is REST my only option?
No, with a SOAP service, you need to use the SOAP methods and actions - you cannot use HTTP POST to "dump" some data on a SOAP service.
If you need HTTP POST, then REST is the way to go.
You can also use REST style WCF
http://msdn.microsoft.com/en-us/netframework/cc950529.aspx