View Full Version : Http POST requests get sent as OPTIONS requests

5 Jul 2011, 1:43 AM
Hi, I'm trying to contact my soap server through the ext.ajax object. My current problem is that an OPTIONS requests get sent in place of a POST request.

Here is my code:

url: 'http://xxxxxxxxx:8088/mockQueryEngine?WSDL',
method: 'POST',
success: function(response, opts) {
var obj = Ext.decode(response.responseText);
failure: function(response, opts) {
console.log('server-side failure with status code ' + response.status);

Then i get an error from the web service:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<faultstring>Unsupported HTTP Method: OPTIONS</faultstring>

I've inspected the network traffic an confirmed that indeed an OPTIONS request is sent.

What's am I doing wrong?

EDIT: Found out that this is not a sencha touch related problem, in fact, this code causes the same strange behaviour:

var xmlhttp=new XMLHttpRequest();

if (xmlhttp.readyState==4 && xmlhttp.status==200){
xmlhttp.setRequestHeader("Content-type","text/xml"); //this line causes the switch from post to options

5 Jul 2011, 7:49 AM
Firefox converts cross-domain AJAX requests to POST.

6 Jul 2011, 12:48 AM
This appears to be a security issue. Browsers are reluctant to send post request cross domain becuase it could mean that a js script on another site could post a forum post on one of your forums or something like that without you knowing.
For this to work, you have to do some initial handshaking and successfully get a response from the server containing:

Access-Control-Allow-Origin: *
Access-Control-Max-Age: 3628800
Access-Control-Allow-Methods: POST

then your browser will allow you to send post requests cross domain.

Is there however some way to add xml-content to a http request using sencha code?
I'm trying to write my own proxy, and I'm currently stuck at how to make an xmlreader read a usual js XMLHttpRequest, but I can't get it to work.