Source Code Cross Referenced for WsdlRequest.java in  » Web-Services » soapui-1.7.5 » com » eviware » soapui » impl » wsdl » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Web Services » soapui 1.7.5 » com.eviware.soapui.impl.wsdl 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         *  soapUI, copyright (C) 2004-2007 eviware.com 
003:         *
004:         *  soapUI is free software; you can redistribute it and/or modify it under the 
005:         *  terms of version 2.1 of the GNU Lesser General Public License as published by 
006:         *  the Free Software Foundation.
007:         *
008:         *  soapUI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without 
009:         *  even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 
010:         *  See the GNU Lesser General Public License for more details at gnu.org.
011:         */
012:
013:        package com.eviware.soapui.impl.wsdl;
014:
015:        import java.beans.PropertyChangeEvent;
016:        import java.beans.PropertyChangeListener;
017:        import java.io.File;
018:        import java.io.IOException;
019:        import java.util.ArrayList;
020:        import java.util.Arrays;
021:        import java.util.HashSet;
022:        import java.util.List;
023:        import java.util.Set;
024:
025:        import javax.swing.ImageIcon;
026:
027:        import org.apache.log4j.Logger;
028:
029:        import com.eviware.soapui.SoapUI;
030:        import com.eviware.soapui.config.AttachmentConfig;
031:        import com.eviware.soapui.config.CallConfig;
032:        import com.eviware.soapui.config.CredentialsConfig;
033:        import com.eviware.soapui.impl.wsdl.submit.RequestTransportRegistry;
034:        import com.eviware.soapui.impl.wsdl.submit.filters.PropertyExpansionRequestFilter;
035:        import com.eviware.soapui.impl.wsdl.submit.transports.http.AttachmentUtils;
036:        import com.eviware.soapui.impl.wsdl.submit.transports.http.WsdlResponse;
037:        import com.eviware.soapui.impl.wsdl.support.CompressedStringSupport;
038:        import com.eviware.soapui.impl.wsdl.support.FileAttachment;
039:        import com.eviware.soapui.impl.wsdl.support.ModelItemIconAnimator;
040:        import com.eviware.soapui.impl.wsdl.support.RequestFileAttachment;
041:        import com.eviware.soapui.model.iface.Attachment;
042:        import com.eviware.soapui.model.iface.Interface;
043:        import com.eviware.soapui.model.iface.MessagePart;
044:        import com.eviware.soapui.model.iface.Request;
045:        import com.eviware.soapui.model.iface.Submit;
046:        import com.eviware.soapui.model.iface.SubmitContext;
047:        import com.eviware.soapui.model.iface.SubmitListener;
048:        import com.eviware.soapui.model.support.InterfaceListenerAdapter;
049:        import com.eviware.soapui.settings.WsdlSettings;
050:        import com.eviware.soapui.support.UISupport;
051:        import com.eviware.soapui.support.types.StringToStringMap;
052:
053:        /**
054:         * Request implementation holding a SOAP request
055:         * 
056:         * @author Ole.Matzura
057:         */
058:
059:        public class WsdlRequest extends AbstractWsdlModelItem<CallConfig>
060:                implements  Request, AttachmentContainer {
061:            public final static Logger log = Logger
062:                    .getLogger(WsdlRequest.class);
063:
064:            public static final String RESPONSE_PROPERTY = WsdlRequest.class
065:                    .getName()
066:                    + "@response";
067:            public static final String RESPONSE_CONTENT_PROPERTY = WsdlRequest.class
068:                    .getName()
069:                    + "@response-content";
070:            public static final String ATTACHMENTS_PROPERTY = WsdlRequest.class
071:                    .getName()
072:                    + "@attachments";
073:            public static final String INLINE_RESPONSE_ATTACHMENTS = WsdlRequest.class
074:                    .getName()
075:                    + "@inline-response-attachments";
076:            public static final String EXPAND_MTOM_RESPONSE_ATTACHMENTS = WsdlRequest.class
077:                    .getName()
078:                    + "@expand-mtom-attachments";
079:            public static final String STRIP_WHITESPACES = WsdlRequest.class
080:                    .getName()
081:                    + "@strip-whitespaces";
082:            public static final String REMOVE_EMPTY_CONTENT = WsdlRequest.class
083:                    .getName()
084:                    + "@remove_empty_content";
085:            public static final String REQUEST_HEADERS_PROPERTY = WsdlRequest.class
086:                    .getName()
087:                    + "@request-headers";
088:            public static final String ENCODE_ATTACHMENTS = WsdlRequest.class
089:                    .getName()
090:                    + "@encode_attachments";
091:            public static final String DISABLE_MULTIPART_ATTACHMENTS = WsdlRequest.class
092:                    .getName()
093:                    + "@disable-multipart-attachments";
094:            public static final String WSS_TIMETOLIVE = WsdlRequest.class
095:                    .getName()
096:                    + "@wss-time-to-live";
097:            public static final String BIND_ADDRESS = WsdlRequest.class
098:                    .getName()
099:                    + "@bind_address";
100:            public static final String OPERATION_PROPERTY = WsdlRequest.class
101:                    .getName()
102:                    + "@operation";
103:
104:            public final static String PW_TYPE_NONE = "None";
105:            public final static String PW_TYPE_DIGEST = "PasswordDigest";
106:            public final static String PW_TYPE_TEXT = "PasswordText";
107:
108:            private WsdlOperation operation;
109:            private WsdlResponse response;
110:            protected List<FileAttachment> attachments = new ArrayList<FileAttachment>();
111:
112:            private RequestIconAnimator iconAnimator;
113:            private Set<SubmitListener> listeners = new HashSet<SubmitListener>();
114:            private List<WsdlAttachmentPart> definedAttachmentParts;
115:            private InternalInterfaceListener interfaceListener = new InternalInterfaceListener();
116:            private String requestContent;
117:
118:            public WsdlRequest(WsdlOperation operation, CallConfig callConfig) {
119:                this (operation, callConfig, false);
120:            }
121:
122:            public WsdlRequest(WsdlOperation operation, CallConfig callConfig,
123:                    boolean forLoadTest) {
124:                super (callConfig, operation, null);
125:
126:                this .operation = operation;
127:
128:                initEndpoints();
129:                initAttachments();
130:
131:                // ensure encoding
132:                if (callConfig.getEncoding() == null
133:                        || callConfig.getEncoding().length() == 0) {
134:                    callConfig.setEncoding("UTF-8");
135:                }
136:
137:                if (!forLoadTest) {
138:                    iconAnimator = initIconAnimator();
139:                    addSubmitListener(iconAnimator);
140:
141:                    operation.getInterface().addPropertyChangeListener(
142:                            interfaceListener);
143:                    operation.getInterface().addInterfaceListener(
144:                            interfaceListener);
145:                }
146:            }
147:
148:            private void initAttachments() {
149:                for (AttachmentConfig ac : getConfig().getAttachmentList()) {
150:                    FileAttachment attachment = new RequestFileAttachment(ac,
151:                            this );
152:                    attachments.add(attachment);
153:                }
154:            }
155:
156:            public void updateConfig(CallConfig request) {
157:                setConfig(request);
158:            }
159:
160:            public ModelItemIconAnimator getIconAnimator() {
161:                return iconAnimator;
162:            }
163:
164:            protected RequestIconAnimator initIconAnimator() {
165:                return new RequestIconAnimator();
166:            }
167:
168:            protected void initEndpoints() {
169:                if (getEndpoint() == null) {
170:                    String[] endpoints = operation.getInterface()
171:                            .getEndpoints();
172:                    if (endpoints.length > 0) {
173:                        setEndpoint(endpoints[0]);
174:                    }
175:                }
176:            }
177:
178:            public String getRequestContent() {
179:                if (getConfig().getRequest() == null)
180:                    getConfig().addNewRequest();
181:
182:                if (requestContent == null)
183:                    requestContent = CompressedStringSupport
184:                            .getString(getConfig().getRequest());
185:
186:                return requestContent;
187:            }
188:
189:            public void setEndpoint(String endpoint) {
190:                String old = getEndpoint();
191:                if (old != null && old.equals(endpoint))
192:                    return;
193:
194:                getConfig().setEndpoint(endpoint);
195:                notifyPropertyChanged(ENDPOINT_PROPERTY, old, endpoint);
196:            }
197:
198:            public String getEndpoint() {
199:                return getConfig().getEndpoint();
200:            }
201:
202:            public String getEncoding() {
203:                return getConfig().getEncoding();
204:            }
205:
206:            public void setEncoding(String encoding) {
207:                String old = getEncoding();
208:                getConfig().setEncoding(encoding);
209:                notifyPropertyChanged(ENCODING_PROPERTY, old, encoding);
210:            }
211:
212:            public StringToStringMap getRequestHeaders() {
213:                return StringToStringMap.fromXml(getSettings().getString(
214:                        REQUEST_HEADERS_PROPERTY, null));
215:            }
216:
217:            public void setRequestHeaders(StringToStringMap map) {
218:                StringToStringMap old = getRequestHeaders();
219:                getSettings().setString(REQUEST_HEADERS_PROPERTY, map.toXml());
220:                notifyPropertyChanged(REQUEST_HEADERS_PROPERTY, old, map);
221:            }
222:
223:            public boolean isInlineResponseAttachments() {
224:                return getSettings().getBoolean(INLINE_RESPONSE_ATTACHMENTS);
225:            }
226:
227:            public void setInlineResponseAttachments(
228:                    boolean inlineResponseAttachments) {
229:                boolean old = getSettings().getBoolean(
230:                        INLINE_RESPONSE_ATTACHMENTS);
231:                getSettings().setBoolean(INLINE_RESPONSE_ATTACHMENTS,
232:                        inlineResponseAttachments);
233:                notifyPropertyChanged(INLINE_RESPONSE_ATTACHMENTS, old,
234:                        inlineResponseAttachments);
235:            }
236:
237:            public boolean isStripWhitespaces() {
238:                return getSettings().getBoolean(STRIP_WHITESPACES);
239:            }
240:
241:            public void setStripWhitespaces(boolean stripWhitespaces) {
242:                boolean old = getSettings().getBoolean(STRIP_WHITESPACES);
243:                getSettings().setBoolean(STRIP_WHITESPACES, stripWhitespaces);
244:                notifyPropertyChanged(STRIP_WHITESPACES, old, stripWhitespaces);
245:            }
246:
247:            public boolean isExpandMtomResponseAttachments() {
248:                return getSettings().getBoolean(
249:                        EXPAND_MTOM_RESPONSE_ATTACHMENTS);
250:            }
251:
252:            public void setExpandMtomResponseAttachments(
253:                    boolean expandMtomResponseAttachments) {
254:                boolean old = getSettings().getBoolean(
255:                        EXPAND_MTOM_RESPONSE_ATTACHMENTS);
256:                getSettings().setBoolean(EXPAND_MTOM_RESPONSE_ATTACHMENTS,
257:                        expandMtomResponseAttachments);
258:                notifyPropertyChanged(EXPAND_MTOM_RESPONSE_ATTACHMENTS, old,
259:                        expandMtomResponseAttachments);
260:            }
261:
262:            /**
263:             * Use getResponse().getContentAsString();
264:             * @deprecated
265:             */
266:
267:            public String getResponseContent() {
268:                return response == null ? null : response.getContentAsString();
269:            }
270:
271:            public WsdlResponse getResponse() {
272:                return response;
273:            }
274:
275:            public WsdlOperation getOperation() {
276:                return operation;
277:            }
278:
279:            public void setOperation(WsdlOperation wsdlOperation) {
280:                WsdlOperation oldOperation = operation;
281:                this .operation = wsdlOperation;
282:
283:                definedAttachmentParts = null;
284:                notifyPropertyChanged(OPERATION_PROPERTY, oldOperation,
285:                        operation);
286:            }
287:
288:            public void setRequestContent(String request) {
289:                String old = getRequestContent();
290:                if (request.equals(old))
291:                    return;
292:
293:                requestContent = request;
294:                definedAttachmentParts = null;
295:                notifyPropertyChanged(REQUEST_PROPERTY, old, request);
296:            }
297:
298:            public void setResponse(WsdlResponse response, SubmitContext context) {
299:                WsdlResponse oldResponse = (WsdlResponse) getResponse();
300:                this .response = response;
301:
302:                notifyPropertyChanged(RESPONSE_PROPERTY, oldResponse, response);
303:            }
304:
305:            public ImageIcon getIcon() {
306:                return iconAnimator.getIcon();
307:            }
308:
309:            public String getUsername() {
310:                CredentialsConfig credentialsConfig = getConfig()
311:                        .getCredentials();
312:                if (credentialsConfig == null)
313:                    return null;
314:
315:                return credentialsConfig.getUsername();
316:            }
317:
318:            public String getPassword() {
319:                CredentialsConfig credentialsConfig = getConfig()
320:                        .getCredentials();
321:                if (credentialsConfig == null)
322:                    return null;
323:
324:                return credentialsConfig.getPassword();
325:            }
326:
327:            public String getDomain() {
328:                CredentialsConfig credentialsConfig = getConfig()
329:                        .getCredentials();
330:                if (credentialsConfig == null)
331:                    return null;
332:
333:                return credentialsConfig.getDomain();
334:            }
335:
336:            public void setUsername(String username) {
337:                CredentialsConfig credentialsConfig = getConfig()
338:                        .getCredentials();
339:                if (credentialsConfig == null)
340:                    credentialsConfig = getConfig().addNewCredentials();
341:
342:                credentialsConfig.setUsername(username);
343:            }
344:
345:            public void setPassword(String password) {
346:                CredentialsConfig credentialsConfig = getConfig()
347:                        .getCredentials();
348:                if (credentialsConfig == null)
349:                    credentialsConfig = getConfig().addNewCredentials();
350:
351:                credentialsConfig.setPassword(password);
352:            }
353:
354:            public void setDomain(String domain) {
355:                CredentialsConfig credentialsConfig = getConfig()
356:                        .getCredentials();
357:                if (credentialsConfig == null)
358:                    credentialsConfig = getConfig().addNewCredentials();
359:
360:                credentialsConfig.setDomain(domain);
361:            }
362:
363:            public void addSubmitListener(SubmitListener listener) {
364:                listeners.add(listener);
365:            }
366:
367:            public void removeSubmitListener(SubmitListener listener) {
368:                listeners.remove(listener);
369:            }
370:
371:            public WsdlSubmit submit(SubmitContext submitContext, boolean async)
372:                    throws SubmitException {
373:                String endpoint = PropertyExpansionRequestFilter
374:                        .expandProperties(submitContext, getEndpoint());
375:                if (endpoint == null || endpoint.trim().length() == 0) {
376:                    UISupport.showErrorMessage("Missing endpoint for request ["
377:                            + getName() + "]");
378:                    return null;
379:                }
380:
381:                try {
382:                    WsdlSubmit submitter = new WsdlSubmit(this ,
383:                            (SubmitListener[]) listeners
384:                                    .toArray(new SubmitListener[listeners
385:                                            .size()]), RequestTransportRegistry
386:                                    .getTransport(endpoint, submitContext));
387:                    submitter.submitRequest(submitContext, async);
388:                    return submitter;
389:                } catch (Exception e) {
390:                    throw new SubmitException(e.toString());
391:                }
392:            }
393:
394:            private class InternalInterfaceListener extends
395:                    InterfaceListenerAdapter implements  PropertyChangeListener {
396:                public void propertyChange(PropertyChangeEvent evt) {
397:                    if (evt.getPropertyName().equals(
398:                            Interface.ENDPOINT_PROPERTY)) {
399:                        String endpoint = getEndpoint();
400:                        if (evt.getOldValue() != null
401:                                && evt.getOldValue().equals(endpoint)) {
402:                            setEndpoint((String) evt.getNewValue());
403:                        }
404:                    }
405:                }
406:            }
407:
408:            public String getWssPasswordType() {
409:                return getConfig().getWssPasswordType();
410:            }
411:
412:            public void setWssPasswordType(String wssPasswordType) {
413:                getConfig().setWssPasswordType(wssPasswordType);
414:            }
415:
416:            /* (non-Javadoc)
417:             * @see com.eviware.soapui.impl.wsdl.AttachmentContainer#attachFile(java.io.File, boolean)
418:             */
419:            public Attachment attachFile(File file, boolean cache) {
420:                try {
421:                    FileAttachment fileAttachment = new RequestFileAttachment(
422:                            file, cache, this );
423:                    attachments.add(fileAttachment);
424:                    notifyPropertyChanged(ATTACHMENTS_PROPERTY, null,
425:                            fileAttachment);
426:                    return fileAttachment;
427:                } catch (IOException e) {
428:                    UISupport.showErrorMessage(e);
429:                    return null;
430:                }
431:            }
432:
433:            /* (non-Javadoc)
434:             * @see com.eviware.soapui.impl.wsdl.AttachmentContainer#getAttachmentCount()
435:             */
436:            public int getAttachmentCount() {
437:                return attachments.size();
438:            }
439:
440:            /* (non-Javadoc)
441:             * @see com.eviware.soapui.impl.wsdl.AttachmentContainer#getAttachmentAt(int)
442:             */
443:            public Attachment getAttachmentAt(int index) {
444:                return attachments.get(index);
445:            }
446:
447:            /* (non-Javadoc)
448:             * @see com.eviware.soapui.impl.wsdl.AttachmentContainer#getAttachmentsForPart(java.lang.String)
449:             */
450:            public Attachment[] getAttachmentsForPart(String partName) {
451:                List<Attachment> result = new ArrayList<Attachment>();
452:
453:                for (Attachment attachment : attachments) {
454:                    if (attachment.getPart().equals(partName))
455:                        result.add(attachment);
456:                }
457:
458:                return result.toArray(new Attachment[result.size()]);
459:            }
460:
461:            /* (non-Javadoc)
462:             * @see com.eviware.soapui.impl.wsdl.AttachmentContainer#removeAttachment(com.eviware.soapui.model.iface.Attachment)
463:             */
464:            public void removeAttachment(Attachment attachment) {
465:                int ix = attachments.indexOf(attachment);
466:                attachments.remove(ix);
467:
468:                try {
469:                    notifyPropertyChanged(ATTACHMENTS_PROPERTY, attachment,
470:                            null);
471:                } finally {
472:                    getConfig().removeAttachment(ix);
473:                }
474:            }
475:
476:            /* (non-Javadoc)
477:             * @see com.eviware.soapui.impl.wsdl.AttachmentContainer#getAttachments()
478:             */
479:            public Attachment[] getAttachments() {
480:                return attachments.toArray(new Attachment[attachments.size()]);
481:            }
482:
483:            /* (non-Javadoc)
484:             * @see com.eviware.soapui.impl.wsdl.AttachmentContainer#getDefinedAttachmentParts()
485:             */
486:            public WsdlAttachmentPart[] getDefinedAttachmentParts() {
487:                if (definedAttachmentParts == null) {
488:                    try {
489:                        UISupport.setHourglassCursor();
490:                        definedAttachmentParts = AttachmentUtils
491:                                .extractAttachmentParts(operation,
492:                                        getRequestContent(), true, false);
493:                    } catch (Exception e) {
494:                        log.warn(e.toString());
495:                        definedAttachmentParts = new ArrayList<WsdlAttachmentPart>();
496:                    } finally {
497:                        UISupport.resetCursor();
498:                    }
499:                }
500:
501:                return definedAttachmentParts
502:                        .toArray(new WsdlAttachmentPart[definedAttachmentParts
503:                                .size()]);
504:            }
505:
506:            /* (non-Javadoc)
507:             * @see com.eviware.soapui.impl.wsdl.AttachmentContainer#getAttachmentPart(java.lang.String)
508:             */
509:            public WsdlAttachmentPart getAttachmentPart(String partName) {
510:                WsdlAttachmentPart[] parts = getDefinedAttachmentParts();
511:                for (WsdlAttachmentPart part : parts) {
512:                    if (part.getName().equals(partName))
513:                        return part;
514:                }
515:
516:                return null;
517:            }
518:
519:            public void copyAttachmentsTo(WsdlRequest newRequest) {
520:                if (getAttachmentCount() > 0) {
521:                    try {
522:                        UISupport.setHourglassCursor();
523:                        for (int c = 0; c < getAttachmentCount(); c++) {
524:                            try {
525:                                Attachment attachment = getAttachmentAt(c);
526:                                newRequest.addAttachment(attachment);
527:                            } catch (Exception e) {
528:                                SoapUI.logError(e);
529:                            }
530:                        }
531:                    } finally {
532:                        UISupport.resetCursor();
533:                    }
534:                }
535:            }
536:
537:            private Attachment addAttachment(Attachment attachment) {
538:                if (attachment instanceof  FileAttachment) {
539:                    AttachmentConfig oldConfig = ((FileAttachment) attachment)
540:                            .getConfig();
541:                    AttachmentConfig newConfig = (AttachmentConfig) getConfig()
542:                            .addNewAttachment().set(oldConfig);
543:                    FileAttachment newAttachment = new RequestFileAttachment(
544:                            newConfig, this );
545:                    attachments.add(newAttachment);
546:                    return newAttachment;
547:                } else
548:                    log.error("Unkown attachment type: " + attachment);
549:
550:                return null;
551:            }
552:
553:            public void copyTo(WsdlRequest newRequest, boolean copyAttachments,
554:                    boolean copyHeaders) {
555:                newRequest.setEncoding(getEncoding());
556:                newRequest.setEndpoint(getEndpoint());
557:                newRequest.setRequestContent(getRequestContent());
558:                newRequest.setWssPasswordType(getWssPasswordType());
559:
560:                CredentialsConfig credentials = getConfig().getCredentials();
561:                if (credentials != null)
562:                    newRequest.getConfig().setCredentials(
563:                            (CredentialsConfig) credentials.copy());
564:
565:                if (copyAttachments)
566:                    copyAttachmentsTo(newRequest);
567:
568:                if (copyHeaders)
569:                    newRequest.setRequestHeaders(getRequestHeaders());
570:            }
571:
572:            /* (non-Javadoc)
573:             * @see com.eviware.soapui.impl.wsdl.AttachmentContainer#isMtomEnabled()
574:             */
575:            public boolean isMtomEnabled() {
576:                return getSettings().getBoolean(WsdlSettings.ENABLE_MTOM);
577:            }
578:
579:            public void setMtomEnabled(boolean mtomEnabled) {
580:                getSettings().setBoolean(WsdlSettings.ENABLE_MTOM, mtomEnabled);
581:                definedAttachmentParts = null;
582:            }
583:
584:            public void release() {
585:                super .release();
586:
587:                getOperation().getInterface().removeInterfaceListener(
588:                        interfaceListener);
589:                getOperation().getInterface().removePropertyChangeListener(
590:                        interfaceListener);
591:            }
592:
593:            public MessagePart[] getRequestParts() {
594:                try {
595:                    List<MessagePart> result = new ArrayList<MessagePart>();
596:                    result.addAll(Arrays.asList(getOperation()
597:                            .getDefaultRequestParts()));
598:                    result.addAll(Arrays.asList(getDefinedAttachmentParts()));
599:
600:                    return result.toArray(new MessagePart[result.size()]);
601:                } catch (Exception e) {
602:                    SoapUI.logError(e);
603:                    return new MessagePart[0];
604:                }
605:            }
606:
607:            public MessagePart[] getResponseParts() {
608:                try {
609:                    List<MessagePart> result = new ArrayList<MessagePart>();
610:                    result.addAll(Arrays.asList(getOperation()
611:                            .getDefaultResponseParts()));
612:
613:                    if (getResponse() != null)
614:                        result.addAll(AttachmentUtils.extractAttachmentParts(
615:                                (WsdlOperation) getOperation(), getResponse()
616:                                        .getContentAsString(), true, true));
617:
618:                    return result.toArray(new MessagePart[result.size()]);
619:                } catch (Exception e) {
620:                    SoapUI.logError(e);
621:                    return new MessagePart[0];
622:                }
623:            }
624:
625:            protected class RequestIconAnimator extends ModelItemIconAnimator
626:                    implements  SubmitListener {
627:                public RequestIconAnimator() {
628:                    super (WsdlRequest.this , "/request.gif", new String[] {
629:                            "/exec_request_1.gif", "/exec_request_2.gif",
630:                            "/exec_request_3.gif", "/exec_request_4.gif" });
631:                }
632:
633:                public boolean beforeSubmit(Submit submit, SubmitContext context) {
634:                    if (isEnabled() && submit.getRequest() == getTarget())
635:                        start();
636:                    return true;
637:                }
638:
639:                public void afterSubmit(Submit submit, SubmitContext context) {
640:                    if (submit.getRequest() == getTarget())
641:                        stop();
642:                }
643:            }
644:
645:            public boolean isMultipartEnabled() {
646:                return !getSettings().getBoolean(DISABLE_MULTIPART_ATTACHMENTS);
647:            }
648:
649:            public void setMultipartEnabled(boolean multipartEnabled) {
650:                getSettings().setBoolean(DISABLE_MULTIPART_ATTACHMENTS,
651:                        !multipartEnabled);
652:            }
653:
654:            public String getWssTimeToLive() {
655:                return getSettings().getString(WSS_TIMETOLIVE, null);
656:            }
657:
658:            public void setWssTimeToLive(String ttl) {
659:                getSettings().setString(WSS_TIMETOLIVE, ttl);
660:            }
661:
662:            @Override
663:            public void onSave() {
664:                if (requestContent != null) {
665:                    CompressedStringSupport.setString(getConfig().getRequest(),
666:                            requestContent);
667:                    requestContent = null;
668:                }
669:            }
670:
671:            public long getContentLength() {
672:                return getRequestContent().length();
673:            }
674:
675:            public boolean isRemoveEmptyContent() {
676:                return getSettings().getBoolean(REMOVE_EMPTY_CONTENT);
677:            }
678:
679:            public void setRemoveEmptyContent(boolean removeEmptyContent) {
680:                boolean old = getSettings().getBoolean(REMOVE_EMPTY_CONTENT);
681:                getSettings().setBoolean(REMOVE_EMPTY_CONTENT,
682:                        removeEmptyContent);
683:                notifyPropertyChanged(REMOVE_EMPTY_CONTENT, old,
684:                        removeEmptyContent);
685:            }
686:
687:            public boolean isEncodeAttachments() {
688:                return getSettings().getBoolean(ENCODE_ATTACHMENTS);
689:            }
690:
691:            public void setEncodeAttachments(boolean encodeAttachments) {
692:                boolean old = getSettings().getBoolean(ENCODE_ATTACHMENTS);
693:                getSettings().setBoolean(ENCODE_ATTACHMENTS, encodeAttachments);
694:                notifyPropertyChanged(ENCODE_ATTACHMENTS, old,
695:                        encodeAttachments);
696:            }
697:
698:            public String getBindAddress() {
699:                return getSettings().getString(BIND_ADDRESS, "");
700:            }
701:
702:            public void setBindAddress(String bindAddress) {
703:                String old = getSettings().getString(BIND_ADDRESS, "");
704:                getSettings().setString(BIND_ADDRESS, bindAddress);
705:                notifyPropertyChanged(BIND_ADDRESS, old, bindAddress);
706:            }
707:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.