PDA

View Full Version : Setting input headers



igniz248
18 Feb 2010, 2:35 PM
Hi

I am reading an XML file from a remote server. The actual connection to the server is functional, however I need to send a HTTP input header value to get the appropriate XML else i get an error XML response like so,

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<error code="VALID_FAILED">
<failure field="Request_Id cause="MISSING_VALUE"/>
</error>

Request_Id is a HTTP input header which is "required" value. The URL I am calling is a REST API. I have tried quite a few possibilities to list em all out here. If anyone has any clues...Please Help.

igniz248
18 Feb 2010, 2:54 PM
Code:

Ext.onReady(function(){

var myproxy = new Ext.data.ScriptTagProxy({url:'http://abc.com/1/currencies',

headers: {'RequesrId': 'dev'}});

myproxy.on({
'beforeload': {
fn: function(store,options)
{
console.log('02 - Proxy Listener Fired (beforeload):',arguments);
}
,scope:this}
,'load':{
fn: function(store, options){
console.log('Proxy listener fired (load), arguments:',arguments);
}
,scope:this
}
,'loadexception':{
fn: function(store, options){
console.log('Proxy listener fired (loadexception), arguments:',arguments);
}
,scope:this
}
});



// create the Data Store
var store = new Ext.data.Store({
// load using HTTP

proxy: myproxy, // the return will be XML, so lets set up a reader

reader: new Ext.data.XmlStringReader({
// records will have an "Item" tag
record: 'currency',


})
});

igniz248
18 Feb 2010, 9:25 PM
Has anyone been able to successfully set the "Accept" value? My request header displays this

User-AgentMozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1.3) Gecko/20090824 Firefox/3.5.3Accept*/*Accept-Languageen-us,en;q=0.5Accept-Encodinggzip,deflate
Help needed badly. My actual xml response is sitting behind this input header without which I am unable to retreive any data,,

goldledoigt
18 Feb 2010, 9:36 PM
I don't think ScriptTagProxy can handle XML server response.
Because server response will be included in <script /> tags you can't get an XML formated return.

igniz248
19 Feb 2010, 3:18 PM
True. There needs to be a callback function to process this according the explanation on this post

http://www.extjs.com/forum/showthread.php?t=12852

However, not quite sure how that needs to be done.

goldledoigt
21 Feb 2010, 11:21 PM
To understand better how it works you should take a look to jsonp.js (http://www.extjs.com/playpen/ext-core-latest/examples/jsonp/jsonp.js) from this Ext Core example :
http://www.extjs.com/playpen/ext-core-latest/examples/jsonp/

I hope this can help you.

Animal
21 Feb 2010, 11:35 PM
True. There needs to be a callback function to process this according the explanation on this post

http://www.extjs.com/forum/showthread.php?t=12852

However, not quite sure how that needs to be done.

There's an example in the API docs!!!

You will never be able to send a header because it just adds a <script> tag as you have been told already.

igniz248
21 Feb 2010, 11:41 PM
Thanks guys.