本帖最后由 panjianjun5 于 2012-12-24 10:28:19 编辑

解决方案 »

  1.   

    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;
        }
    });
       
      

  2.   

    找到问题了,是因为我用的是4.1.1的SDK,但是我下载的Proxy和Reader是4.1.3的,我用4.1.3的XTempalteCompiler就行了