]>
git.proxmox.com Git - extjs.git/blob - extjs/packages/soap/src/data/soap/Proxy.js
3 * The SOAP Proxy class is an {@link Ext.data.proxy.Ajax Ajax Proxy} to access v1.1 SOAP
4 * (Simple Object Access Protocol) services. SOAP Proxy constructs a SOAP Envelope and
5 * submits an AJAX request to load a SOAP response from the server.
7 * For help getting started please refer to the [Soap Guide](../../../enterprise/soap.html).
9 * **Note: ** _This functionality is only available with the purchase of
10 * Sencha Complete. For more information about using this class, please visit
11 * our [Sencha Complete](https://www.sencha.com/products/complete/) product page._
13 * @class Ext.data.soap.Proxy
15 Ext
.define('Ext.data.soap.Proxy', {
16 extend
: 'Ext.data.proxy.Ajax',
20 'Ext.data.soap.Reader'
26 * An object containing "create", "read", "update" and "destroy" properties that define
27 * SOAP operations for each CRUD action method. These operations will be appended to
28 * the {@link #url} as the {@link #operationParam} for each request type.
37 * At least one operation is required, but additional operations do not need to be configured
38 * if they will not be used. For example, if this proxy is only used for read operations
39 * the following configuration will be sufficient:
47 * @cfg {Object} soapAction
48 * An object containing "create", "read", "update" and "destroy" properties that define
49 * the [SOAPAction](http://www.w3.org/TR/2000/NOTE-SOAP-20000508/#_Toc478383528) header
50 * for each CRUD action method. A soapAction must be specified for each operation
51 * configured in {@link #api} Defaults to:
63 * @cfg {String} [operationParam='op']
64 * The name of the operation parameter to be appened to the SOAP endpoint url
69 * @cfg {Object/String/Ext.data.soap.Reader} [reader='soap']
70 * The {@link Ext.data.soap.Reader} to use to decode the server's response. This can
71 * either be a SOAP Reader instance, a SOAP Reader config object or 'soap'.
77 * The SOAP endpoint url that this proxy will use to request the SOAP data. This can
78 * be a proxied url to work around same-origin policy if the SOAP endpoint url is on
79 * a different domain from your application.
84 * @cfg [envelopeTpl=undefined]
85 * The template used to create the SOAP envelope. Defaults to:
88 * '<?xml version="1.0" encoding="utf-8" ?>',
89 * '<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">',
90 * '{[values.bodyTpl.apply(values)]}',
95 '<?xml version="1.0" encoding="utf-8" ?>',
96 '<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">',
97 '{[values.bodyTpl.apply(values)]}',
102 * @cfg {Ext.XTemplate/Array} createBodyTpl
103 * The template used to create the SOAP body for the "create" action. If not specified
104 * {@link #writeBodyTpl} will be used for the "create" action.
109 * @cfg {Ext.XTemplate/Array} [readBodyTpl=undefined]
110 * The template used to create the SOAP body for the "read" action. Defaults to:
114 * '<{operation} xmlns="{targetNamespace}">',
115 * '<tpl foreach="params">',
124 '<{operation} xmlns="{targetNamespace}">',
125 '<tpl foreach="params">',
133 * @cfg {Ext.XTemplate/Array} updateBodyTpl
134 * The template used to create the SOAP body for the "update" action. If not specified
135 * {@link #writeBodyTpl} will be used for the "update" action.
140 * @cfg {Ext.XTemplate/Array} destroyBodyTpl
141 * The template used to create the SOAP body for the "destroy" action. If not specified
142 * {@link #writeBodyTpl} will be used for the "destroy" action.
144 destroyBodyTpl
: null,
147 * @cfg {Ext.XTemplate/Array} [writeBodyTpl=undefined]
148 * The default template used to create the SOAP body for write actions (create, update,
149 * and destroy). The individual body templates for each write action can be configured
150 * using {@link #createBodyTpl}, {@link #updateBodyTpl}, and {@link #destroyBodyTpl}.
155 * '<{operation} xmlns="{targetNamespace}">',
156 * '<tpl for="records">',
157 * '{% var recordName=values.modelName.split(".").pop(); %}',
158 * '<{[recordName]}>',
159 * '<tpl for="fields">',
160 * '<{name}>{[parent.get(values.name)]}</{name}>',
162 * '</{[recordName]}>',
170 '<{operation} xmlns="{targetNamespace}">',
171 '<tpl for="records">',
172 '{% var recordName=values.modelName.split(".").pop(); %}',
174 '<tpl for="fields">',
175 '<{name}>{[parent.get(values.name)]}</{name}>',
184 * @cfg {String} targetNamespace
185 * namespace URI used by {@link #createBodyTpl}, {@link #readBodyTpl}, {@link #updateBodyTpl},
186 * and {@link #destroyBodyTpl} as the "xmlns" attribute for the operation element.
191 applyEnvelopeTpl: function(tpl
) {
192 return this.createTpl(tpl
);
195 applyCreateBodyTpl: function(tpl
) {
196 return this.createTpl(tpl
);
199 applyReadBodyTpl: function(tpl
) {
200 return this.createTpl(tpl
);
203 applyUpdateBodyTpl: function(tpl
) {
204 return this.createTpl(tpl
);
207 applyDestroyBodyTpl: function(tpl
) {
208 return this.createTpl(tpl
);
211 applyWriteBodyTpl: function(tpl
) {
212 return this.createTpl(tpl
);
215 createTpl: function(tpl
) {
216 if (tpl
&& !tpl
.isTpl
) {
217 tpl
= new Ext
.XTemplate(tpl
);
223 * @property {Object} actionMethods
225 * Mapping of action name to HTTP request method. All SOAP actions are mapped to 'POST'
228 doRequest: function(operation
) {
230 action
= operation
.getAction(),
231 soapOperation
= me
.getApi()[action
],
232 params
= Ext
.applyIf(operation
.getParams() || {}, me
.getExtraParams() || {}),
233 xmlData
= me
.getEnvelopeTpl().apply({
234 operation
: soapOperation
,
235 targetNamespace
: me
.getTargetNamespace(),
237 records
: operation
.getRecords(),
238 bodyTpl
: me
.getBodyTpl(action
)
240 request
= new Ext
.data
.Request({
241 url
: me
.getUrl() + '?' + me
.getOperationParam() + '=' + soapOperation
,
244 operation
: operation
,
247 SOAPAction
: me
.getSoapAction()[action
]
249 timeout
: me
.getTimeout(),
251 disableCaching
: false // explicitly set it to false, ServerProxy handles caching
254 request
.setCallback(me
.createRequestCallback(request
, operation
));
255 return me
.sendRequest(request
);
258 getBodyTpl: function(action
) {
259 action
= Ext
.String
.capitalize(action
);
260 var tpl
= this['get' + action
+ 'BodyTpl']();
261 return tpl
|| this.getWriteBodyTpl();