Using CORS + SOAP + WCF for HTTPS

I am trying to get CORS to work for the new version of our SOAP web service (which works under HTTPS and has username and password authentication), which can be connected via JS.

I am currently working fine (not cross-domain), but soon when it uses a different domain, I get the following from WCF Traceviewer. (400 invalid requests in IIS7)

<ExceptionString>System.Xml.XmlException: The body of the message cannot be read because it is empty.</ExceptionString> 

It doesn't seem to even get to the part where my message inspector works to add the appropriate CORS headers.

Has anyone experienced this before or managed to get CORS to work in the HTTPS SOAP service?

I would appreciate any advice you can give.

Cheers, Jamie

+6
source share
1 answer

In fact, you can do this to implement your own custom response header for a request like this.

 Response.AppendHeader("Access-Control-Allow-Origin", "*"); 

There are many ways to do this. You can only overcome. Are you viewing cross-domain access in wcf articles? A project has been implemented that uses a wcf service from wcf and wcf service nodes in a cross domain. You can use jsonp with webhttp binding. sample answer here;

Cross domain jQuery Ajax request and REST service for WCF

or you can implement this configuration:

 <system.webServer> <httpProtocol> <customHeaders> <add name="Access-Control-Allow-Origin" value="*" /> </customHeaders> </httpProtocol> </system.webServer> 

For a better way to implement / enable corsa, please check enable-cors.org. I can easily find this link.

http://enable-cors.org/server_wcf.html

At least you can use jsonp instead of json. it's free, but it’s hard to do.

Interestingly, you hired him.

+1
source

Source: https://habr.com/ru/post/950130/


All Articles