I'm trying to get CORS working for a new version of our SOAP web service (which runs under HTTPS and has username/password authentication) which can be connected to via JS.
At the moment I'm getting it working fine locally (not cross-domain) but soon as it is using a different domain I get the following from the WCF Traceviewer. (400 Bad Request in IIS7)
<ExceptionString>System.Xml.XmlException: The body of the message cannot be read because it is empty.</ExceptionString>
It seems it's not even getting to the part where my message inspector runs to add the appropriate CORS headers.
Has anyone experienced this before or managed to get CORS to work under a HTTPS SOAP service?
I'd appreciate any advice you can give.
Cheers, Jamie
Actually you can do this only implement the response custom header per request like this.
Response.AppendHeader("Access-Control-Allow-Origin", "*");
There are more ways to do this. You can only chooise is. Do you look the enabling cross domain access on wcf articles? Implemented a project used wcf service from wcf and wcf service hosts on cross domain. You can use jsonp with webhttp binding. example answer is here;
Cross Domain jQuery Ajax Request & WCF REST Service
or you can implement configuration like this:
<system.webServer>
<httpProtocol>
<customHeaders>
<add name="Access-Control-Allow-Origin" value="*" />
</customHeaders>
</httpProtocol>
</system.webServer>
For best way to implement/enabling cors please check the enable-cors.org site. i can found easyly that link.
http://enable-cors.org/server_wcf.html
At least you can use jsonp instead of json. its free you but difficult to handle.
I wonder what you chooise it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With