87,904
社区成员
发帖
与我相关
我的任务
分享
Ext.define('Ext.data.soap.Proxy', {
extend: 'Ext.data.proxy.Ajax',
alias: 'proxy.soap',
requires: [
'Ext.data.soap.Reader'
],
operationParam: 'op',
reader: 'soap',
envelopeTpl: [
'<?xml version="1.0" encoding="utf-8" ?>',
'<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">',
'{[values.bodyTpl.apply(values)]}',
'</soap:Envelope>'
],
readBodyTpl: [
'<soap:Body>',
'<{operation} xmlns="{targetNamespace}">',
'<tpl foreach="params">',
'<{$}>{.}</{$}>',
'</tpl>',
'</{operation}>',
'</soap:Body>'
],
writeBodyTpl: [
'<soap:Body>',
'<{operation} xmlns="{targetNamespace}">',
'<tpl for="records">',
'{% var recordName=values.modelName.split(".").pop(); %}',
'<{[recordName]}>',
'<tpl for="fields">',
'<{name}>{[parent.get(values.name)]}</{name}>',
'</tpl>',
'</{[recordName]}>',
'</tpl>',
'</{operation}>',
'</soap:Body>'
],
constructor: function(config) {
this.callParent(arguments);
this.api = config.api || {};
this.soapAction = config.soapAction || {};
},
doRequest: function(operation, callback, scope) {
var me = this,
XTemplate = Ext.XTemplate,
action = operation.action,
soapOperation = me.api[action],
params = Ext.applyIf(operation.params || {}, me.extraParams || {}),
bodyTplName = action + 'BodyTpl',
xmlData = XTemplate.getTpl(me, 'envelopeTpl').apply({
operation: soapOperation,
targetNamespace: me.targetNamespace,
params: params,
records: operation.records,
bodyTpl: XTemplate.getTpl(me, me[bodyTplName] ? bodyTplName : 'writeBodyTpl')
}),
request = new Ext.data.Request({
url: me.url + '?' + me.operationParam + '=' + soapOperation,
method: 'POST',
action: action,
operation: operation,
xmlData: xmlData,
headers: Ext.apply({
SOAPAction: me.soapAction[action]
}, me.headers),
timeout: me.timeout,
scope: me,
disableCaching: false // explicitly set it to false, ServerProxy handles caching
});
request.callback = request.callback = function(response,opts){
console.log(action);
console.log(soapOperation);
console.log(params);
console.log(bodyTplName);
console.log(xmlData);
console.log(me[bodyTplName]);
};//me.createRequestCallback(request, operation, callback, scope);
Ext.Ajax.request(request);
return request;
}
});