1
2
3
4
5
6
7
8
9
10
11
12
13 package com.eviware.soapui.impl.wsdl;
14
15 import java.beans.PropertyChangeEvent;
16 import java.beans.PropertyChangeListener;
17 import java.io.File;
18 import java.io.IOException;
19 import java.util.ArrayList;
20 import java.util.Arrays;
21 import java.util.Collections;
22 import java.util.HashSet;
23 import java.util.List;
24 import java.util.Set;
25
26 import javax.swing.ImageIcon;
27
28 import org.apache.log4j.Logger;
29
30 import com.eviware.soapui.SoapUI;
31 import com.eviware.soapui.config.AttachmentConfig;
32 import com.eviware.soapui.config.CallConfig;
33 import com.eviware.soapui.config.CredentialsConfig;
34 import com.eviware.soapui.impl.wsdl.submit.RequestTransportRegistry;
35 import com.eviware.soapui.impl.wsdl.submit.transports.http.AttachmentUtils;
36 import com.eviware.soapui.impl.wsdl.submit.transports.http.WsdlResponse;
37 import com.eviware.soapui.impl.wsdl.support.CompressedStringSupport;
38 import com.eviware.soapui.impl.wsdl.support.FileAttachment;
39 import com.eviware.soapui.impl.wsdl.support.ModelItemIconAnimator;
40 import com.eviware.soapui.impl.wsdl.support.RequestFileAttachment;
41 import com.eviware.soapui.model.ModelItem;
42 import com.eviware.soapui.model.iface.Attachment;
43 import com.eviware.soapui.model.iface.Interface;
44 import com.eviware.soapui.model.iface.MessagePart;
45 import com.eviware.soapui.model.iface.Request;
46 import com.eviware.soapui.model.iface.Submit;
47 import com.eviware.soapui.model.iface.SubmitContext;
48 import com.eviware.soapui.model.iface.SubmitListener;
49 import com.eviware.soapui.model.propertyexpansion.PropertyExpansion;
50 import com.eviware.soapui.model.propertyexpansion.PropertyExpansionContainer;
51 import com.eviware.soapui.model.propertyexpansion.PropertyExpansionUtils;
52 import com.eviware.soapui.model.support.InterfaceListenerAdapter;
53 import com.eviware.soapui.settings.WsdlSettings;
54 import com.eviware.soapui.support.StringUtils;
55 import com.eviware.soapui.support.UISupport;
56 import com.eviware.soapui.support.types.StringToStringMap;
57
58 /***
59 * Request implementation holding a SOAP request
60 *
61 * @author Ole.Matzura
62 */
63
64 public class WsdlRequest extends AbstractWsdlModelItem<CallConfig> implements Request,
65 AttachmentContainer, PropertyExpansionContainer
66 {
67 public final static Logger log = Logger.getLogger( WsdlRequest.class );
68
69 public static final String RESPONSE_PROPERTY = WsdlRequest.class.getName() + "@response";
70 public static final String RESPONSE_CONTENT_PROPERTY = WsdlRequest.class.getName() + "@response-content";
71 public static final String ATTACHMENTS_PROPERTY = WsdlRequest.class.getName() + "@attachments";
72 public static final String INLINE_RESPONSE_ATTACHMENTS = WsdlRequest.class.getName() + "@inline-response-attachments";
73 public static final String EXPAND_MTOM_RESPONSE_ATTACHMENTS = WsdlRequest.class.getName() + "@expand-mtom-attachments";
74 public static final String STRIP_WHITESPACES = WsdlRequest.class.getName() + "@strip-whitespaces";
75 public static final String FORCE_MTOM = WsdlRequest.class.getName() + "@force_mtom";
76 public static final String REMOVE_EMPTY_CONTENT = WsdlRequest.class.getName() + "@remove_empty_content";
77 public static final String ENABLE_INLINE_FILES = WsdlRequest.class.getName() + "@enable_inline_files";
78 public static final String SKIP_SOAP_ACTION = WsdlRequest.class.getName() + "@skip_soap_action";
79 public static final String REQUEST_HEADERS_PROPERTY = WsdlRequest.class.getName() + "@request-headers";
80 public static final String ENCODE_ATTACHMENTS = WsdlRequest.class.getName() + "@encode_attachments";
81 public static final String DISABLE_MULTIPART_ATTACHMENTS = WsdlRequest.class.getName() + "@disable-multipart-attachments";
82 public static final String WSS_TIMETOLIVE = WsdlRequest.class.getName() + "@wss-time-to-live";
83 public static final String BIND_ADDRESS = WsdlRequest.class.getName() + "@bind_address";
84 public static final String OPERATION_PROPERTY = WsdlRequest.class.getName() + "@operation";
85 public static final String INCOMING_WSS = WsdlRequest.class.getName() + "@incoming-wss";
86 public static final String OUGOING_WSS = WsdlRequest.class.getName() + "@outgoing-wss";
87
88 public final static String PW_TYPE_NONE="None";
89 public final static String PW_TYPE_DIGEST="PasswordDigest";
90 public final static String PW_TYPE_TEXT="PasswordText";
91
92 private WsdlOperation operation;
93 private WsdlResponse response;
94 protected List<FileAttachment> attachments = new ArrayList<FileAttachment>();
95
96 private RequestIconAnimator iconAnimator;
97 private Set<SubmitListener> submitListeners = new HashSet<SubmitListener>();
98 private List<WsdlAttachmentPart> definedAttachmentParts;
99 private InternalInterfaceListener interfaceListener = new InternalInterfaceListener();
100 private String requestContent;
101
102
103
104 public WsdlRequest( WsdlOperation operation, CallConfig callConfig )
105 {
106 this( operation, callConfig, false );
107 }
108
109 public WsdlRequest( WsdlOperation operation, CallConfig callConfig, boolean forLoadTest )
110 {
111 super( callConfig, operation, null );
112
113 this.operation = operation;
114
115 initEndpoints();
116 initAttachments();
117
118
119 if( callConfig.getEncoding() == null || callConfig.getEncoding().length() == 0 )
120 {
121 callConfig.setEncoding( "UTF-8" );
122 }
123
124 if( !forLoadTest )
125 {
126 iconAnimator = initIconAnimator();
127 addSubmitListener( iconAnimator );
128
129 operation.getInterface().addPropertyChangeListener( interfaceListener );
130 operation.getInterface().addInterfaceListener( interfaceListener );
131 }
132
133 for (SubmitListener listener : SoapUI.getListenerRegistry().getListeners( SubmitListener.class ))
134 {
135 addSubmitListener(listener);
136 }
137 }
138
139 private void initAttachments()
140 {
141 for( AttachmentConfig ac : getConfig().getAttachmentList() )
142 {
143 FileAttachment attachment = new RequestFileAttachment( ac, this );
144 attachments.add( attachment);
145 }
146 }
147
148 public void updateConfig(CallConfig request)
149 {
150 setConfig( request );
151
152
153 }
154
155 public ModelItemIconAnimator getIconAnimator()
156 {
157 return iconAnimator;
158 }
159
160 protected RequestIconAnimator initIconAnimator()
161 {
162 return new RequestIconAnimator();
163 }
164
165 protected void initEndpoints()
166 {
167 if( getEndpoint() == null )
168 {
169 String[] endpoints = operation.getInterface().getEndpoints();
170 if( endpoints.length > 0 )
171 {
172 setEndpoint( endpoints[0] );
173 }
174 }
175 }
176
177 public String getRequestContent()
178 {
179 if( getConfig().getRequest() == null )
180 getConfig().addNewRequest();
181
182 if( requestContent == null )
183 requestContent = CompressedStringSupport.getString( getConfig().getRequest() );
184
185 return requestContent;
186 }
187
188 public void setEndpoint(String endpoint)
189 {
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 {
200 return getConfig().getEndpoint();
201 }
202
203 public String getEncoding()
204 {
205 return getConfig().getEncoding();
206 }
207
208 public void setEncoding(String encoding)
209 {
210 String old = getEncoding();
211 getConfig().setEncoding( encoding );
212 notifyPropertyChanged( ENCODING_PROPERTY, old, encoding );
213 }
214
215 public StringToStringMap getRequestHeaders()
216 {
217 return StringToStringMap.fromXml( getSettings().getString( REQUEST_HEADERS_PROPERTY, null ));
218 }
219
220 public void setRequestHeaders( StringToStringMap map )
221 {
222 StringToStringMap old = getRequestHeaders();
223 getSettings().setString( REQUEST_HEADERS_PROPERTY, map.toXml() );
224 notifyPropertyChanged( REQUEST_HEADERS_PROPERTY, old, map );
225 }
226
227 public boolean isInlineResponseAttachments()
228 {
229 return getSettings().getBoolean( INLINE_RESPONSE_ATTACHMENTS );
230 }
231
232 public void setInlineResponseAttachments( boolean inlineResponseAttachments )
233 {
234 boolean old = getSettings().getBoolean( INLINE_RESPONSE_ATTACHMENTS );
235 getSettings().setBoolean( INLINE_RESPONSE_ATTACHMENTS, inlineResponseAttachments );
236 notifyPropertyChanged( INLINE_RESPONSE_ATTACHMENTS, old, inlineResponseAttachments );
237 }
238
239 public boolean isStripWhitespaces()
240 {
241 return getSettings().getBoolean( STRIP_WHITESPACES );
242 }
243
244 public void setStripWhitespaces( boolean stripWhitespaces )
245 {
246 boolean old = getSettings().getBoolean( STRIP_WHITESPACES );
247 getSettings().setBoolean( STRIP_WHITESPACES, stripWhitespaces );
248 notifyPropertyChanged( STRIP_WHITESPACES, old, stripWhitespaces );
249 }
250
251 public boolean isExpandMtomResponseAttachments()
252 {
253 return getSettings().getBoolean( EXPAND_MTOM_RESPONSE_ATTACHMENTS );
254 }
255
256 public void setExpandMtomResponseAttachments( boolean expandMtomResponseAttachments )
257 {
258 boolean old = getSettings().getBoolean( EXPAND_MTOM_RESPONSE_ATTACHMENTS );
259 getSettings().setBoolean( EXPAND_MTOM_RESPONSE_ATTACHMENTS, expandMtomResponseAttachments );
260 notifyPropertyChanged( EXPAND_MTOM_RESPONSE_ATTACHMENTS, old, expandMtomResponseAttachments );
261 }
262
263 /***
264 * Use getResponse().getContentAsString();
265 * @deprecated
266 */
267
268 @Deprecated
269 public String getResponseContent()
270 {
271 return response == null ? null : response.getContentAsString();
272 }
273
274 public WsdlResponse getResponse()
275 {
276 return response;
277 }
278
279 public WsdlOperation getOperation()
280 {
281 return operation;
282 }
283
284 public void setOperation( WsdlOperation wsdlOperation )
285 {
286 WsdlOperation oldOperation = operation;
287 this.operation = wsdlOperation;
288
289 definedAttachmentParts = null;
290 notifyPropertyChanged( OPERATION_PROPERTY, oldOperation, operation );
291 }
292
293 public void setRequestContent(String request)
294 {
295 String old = getRequestContent();
296 if( request.equals( old ))
297 return;
298
299 requestContent = request;
300 definedAttachmentParts = null;
301 notifyPropertyChanged( REQUEST_PROPERTY, old, request );
302 }
303
304 public void setResponse( WsdlResponse response, SubmitContext context )
305 {
306 WsdlResponse oldResponse = getResponse();
307 this.response = response;
308
309 notifyPropertyChanged( RESPONSE_PROPERTY, oldResponse, response );
310 }
311
312 @Override
313 public ImageIcon getIcon()
314 {
315 return iconAnimator.getIcon();
316 }
317
318 public String getUsername()
319 {
320 CredentialsConfig credentialsConfig = getConfig().getCredentials();
321 if( credentialsConfig == null ) return null;
322
323 return credentialsConfig.getUsername();
324 }
325
326 public String getPassword()
327 {
328 CredentialsConfig credentialsConfig = getConfig().getCredentials();
329 if( credentialsConfig == null ) return null;
330
331 return credentialsConfig.getPassword();
332 }
333
334 public String getDomain()
335 {
336 CredentialsConfig credentialsConfig = getConfig().getCredentials();
337 if( credentialsConfig == null ) return null;
338
339 return credentialsConfig.getDomain();
340 }
341
342 public void setUsername( String username )
343 {
344 CredentialsConfig credentialsConfig = getConfig().getCredentials();
345 if( credentialsConfig == null )
346 credentialsConfig = getConfig().addNewCredentials();
347
348 credentialsConfig.setUsername( username );
349 }
350
351 public void setPassword( String password )
352 {
353 CredentialsConfig credentialsConfig = getConfig().getCredentials();
354 if( credentialsConfig == null )
355 credentialsConfig = getConfig().addNewCredentials();
356
357 credentialsConfig.setPassword( password );
358 }
359
360 public void setDomain( String domain )
361 {
362 CredentialsConfig credentialsConfig = getConfig().getCredentials();
363 if( credentialsConfig == null )
364 credentialsConfig = getConfig().addNewCredentials();
365
366 credentialsConfig.setDomain( domain );
367 }
368
369 public void addSubmitListener(SubmitListener listener)
370 {
371 submitListeners.add( listener );
372 }
373
374 public void removeSubmitListener(SubmitListener listener)
375 {
376 submitListeners.remove( listener );
377 }
378
379 public WsdlSubmit submit( SubmitContext submitContext, boolean async ) throws SubmitException
380 {
381 String endpoint = PropertyExpansionUtils.expandProperties( submitContext, getEndpoint());
382 if( endpoint == null || endpoint.trim().length() == 0 )
383 {
384 UISupport.showErrorMessage( "Missing endpoint for request [" + getName() + "]" );
385 return null;
386 }
387
388 try
389 {
390 WsdlSubmit submitter = new WsdlSubmit(this, submitListeners.toArray(new SubmitListener[submitListeners
391 .size()]), RequestTransportRegistry.getTransport(endpoint, submitContext));
392 submitter.submitRequest(submitContext, async);
393 return submitter;
394 }
395 catch( Exception e )
396 {
397 throw new SubmitException( e.toString() );
398 }
399 }
400
401 private class InternalInterfaceListener extends InterfaceListenerAdapter implements PropertyChangeListener
402 {
403 public void propertyChange(PropertyChangeEvent evt)
404 {
405 if( evt.getPropertyName().equals( Interface.ENDPOINT_PROPERTY ))
406 {
407 String endpoint = getEndpoint();
408 if( evt.getOldValue() != null && evt.getOldValue().equals( endpoint ))
409 {
410 setEndpoint( (String) evt.getNewValue() );
411 }
412 }
413 }
414 }
415
416 public String getWssPasswordType()
417 {
418 String wssPasswordType = getConfig().getWssPasswordType();
419 return StringUtils.isNullOrEmpty( wssPasswordType ) || PW_TYPE_NONE.equals( wssPasswordType ) ? null : wssPasswordType;
420 }
421
422 public void setWssPasswordType(String wssPasswordType)
423 {
424 if( wssPasswordType == null || wssPasswordType.equals( PW_TYPE_NONE ))
425 {
426 if( getConfig().isSetWssPasswordType() )
427 getConfig().unsetWssPasswordType();
428 }
429 else
430 {
431 getConfig().setWssPasswordType( wssPasswordType );
432 }
433 }
434
435
436
437
438 public Attachment attachFile( File file, boolean cache )
439 {
440 try
441 {
442 FileAttachment fileAttachment = new RequestFileAttachment( file, cache, this );
443 attachments.add( fileAttachment );
444 notifyPropertyChanged(ATTACHMENTS_PROPERTY, null, fileAttachment );
445 return fileAttachment;
446 }
447 catch (IOException e)
448 {
449 UISupport.showErrorMessage( e );
450 return null;
451 }
452 }
453
454
455
456
457 public int getAttachmentCount()
458 {
459 return attachments.size();
460 }
461
462
463
464
465 public Attachment getAttachmentAt( int index )
466 {
467 return attachments.get( index );
468 }
469
470
471
472
473 public Attachment [] getAttachmentsForPart( String partName )
474 {
475 List<Attachment> result = new ArrayList<Attachment>();
476
477 for( Attachment attachment : attachments )
478 {
479 if( attachment.getPart().equals( partName ))
480 result.add( attachment );
481 }
482
483 return result.toArray( new Attachment[result.size()]);
484 }
485
486
487
488
489 public void removeAttachment( Attachment attachment )
490 {
491 int ix = attachments.indexOf( attachment );
492 attachments.remove( ix );
493
494 try
495 {
496 notifyPropertyChanged(ATTACHMENTS_PROPERTY, attachment, null );
497 }
498 finally
499 {
500 getConfig().removeAttachment( ix);
501 }
502 }
503
504
505
506
507 public Attachment[] getAttachments()
508 {
509 return attachments.toArray( new Attachment[attachments.size()] );
510 }
511
512
513
514
515 public WsdlAttachmentPart [] getDefinedAttachmentParts()
516 {
517 if( definedAttachmentParts == null )
518 {
519 try
520 {
521 UISupport.setHourglassCursor();
522 definedAttachmentParts = AttachmentUtils.extractAttachmentParts(
523 operation, getRequestContent(), true, false );
524 }
525 catch (Exception e)
526 {
527 log.warn( e.toString() );
528 definedAttachmentParts = new ArrayList<WsdlAttachmentPart>();
529 }
530 finally
531 {
532 UISupport.resetCursor();
533 }
534 }
535
536 return definedAttachmentParts.toArray( new WsdlAttachmentPart[definedAttachmentParts.size()] );
537 }
538
539
540
541
542 public WsdlAttachmentPart getAttachmentPart( String partName )
543 {
544 WsdlAttachmentPart[] parts = getDefinedAttachmentParts();
545 for( WsdlAttachmentPart part : parts )
546 {
547 if( part.getName().equals( partName ))
548 return part;
549 }
550
551 return null;
552 }
553
554 public void copyAttachmentsTo(WsdlRequest newRequest)
555 {
556 if( getAttachmentCount() > 0 )
557 {
558 try
559 {
560 UISupport.setHourglassCursor();
561 for (int c = 0; c < getAttachmentCount(); c++)
562 {
563 try
564 {
565 Attachment attachment = getAttachmentAt(c);
566 newRequest.importAttachment( attachment );
567 }
568 catch (Exception e)
569 {
570 SoapUI.logError( e );
571 }
572 }
573 }
574 finally
575 {
576 UISupport.resetCursor();
577 }
578 }
579 }
580
581 public Attachment importAttachment(Attachment attachment)
582 {
583 if( attachment instanceof FileAttachment )
584 {
585 AttachmentConfig oldConfig = ((FileAttachment)attachment).getConfig();
586 AttachmentConfig newConfig = (AttachmentConfig) getConfig().addNewAttachment().set( oldConfig );
587 FileAttachment newAttachment = new RequestFileAttachment( newConfig, this );
588 attachments.add( newAttachment);
589 return newAttachment;
590 }
591 else log.error( "Unkown attachment type: " + attachment );
592
593 return null;
594 }
595
596 public void copyTo(WsdlRequest newRequest, boolean copyAttachments, boolean copyHeaders)
597 {
598 newRequest.setEncoding( getEncoding() );
599 newRequest.setEndpoint( getEndpoint() );
600 newRequest.setRequestContent( getRequestContent() );
601 newRequest.setWssPasswordType( getWssPasswordType() );
602
603 CredentialsConfig credentials = getConfig().getCredentials();
604 if( credentials != null)
605 newRequest.getConfig().setCredentials( (CredentialsConfig) credentials.copy() );
606
607 if( copyAttachments )
608 copyAttachmentsTo( newRequest );
609
610 if( copyHeaders )
611 newRequest.setRequestHeaders( getRequestHeaders() );
612
613
614 }
615
616
617
618
619 public boolean isMtomEnabled()
620 {
621 return getSettings().getBoolean( WsdlSettings.ENABLE_MTOM );
622 }
623
624 public void setMtomEnabled( boolean mtomEnabled )
625 {
626 getSettings().setBoolean( WsdlSettings.ENABLE_MTOM, mtomEnabled );
627 definedAttachmentParts = null;
628 }
629
630 public boolean isInlineFilesEnabled()
631 {
632 return getSettings().getBoolean( WsdlRequest.ENABLE_INLINE_FILES );
633 }
634
635 public void setInlineFilesEnabled( boolean inlineFilesEnabled )
636 {
637 getSettings().setBoolean( WsdlRequest.ENABLE_INLINE_FILES, inlineFilesEnabled );
638 }
639
640 public boolean isSkipSoapAction()
641 {
642 return getSettings().getBoolean( WsdlRequest.SKIP_SOAP_ACTION);
643 }
644
645 public void setSkipSoapAction( boolean skipSoapAction )
646 {
647 getSettings().setBoolean( WsdlRequest.SKIP_SOAP_ACTION, skipSoapAction );
648 }
649
650 @Override
651 public void release()
652 {
653 super.release();
654
655 getOperation().getInterface().removeInterfaceListener( interfaceListener );
656 getOperation().getInterface().removePropertyChangeListener( interfaceListener );
657
658 submitListeners.clear();
659 }
660
661 public MessagePart[] getRequestParts()
662 {
663 try
664 {
665 List<MessagePart> result = new ArrayList<MessagePart>();
666 result.addAll( Arrays.asList( getOperation().getDefaultRequestParts() ));
667 result.addAll( Arrays.asList( getDefinedAttachmentParts()) );
668
669 return result.toArray( new MessagePart[result.size()] );
670 }
671 catch (Exception e)
672 {
673 SoapUI.logError( e );
674 return new MessagePart [0];
675 }
676 }
677
678 public MessagePart[] getResponseParts()
679 {
680 try
681 {
682 List<MessagePart> result = new ArrayList<MessagePart>();
683 result.addAll( Arrays.asList( getOperation().getDefaultResponseParts() ));
684
685 if( getResponse() != null )
686 result.addAll( AttachmentUtils.extractAttachmentParts(
687 getOperation(), getResponse().getContentAsString(), true, true ));
688
689 return result.toArray( new MessagePart[result.size()] );
690 }
691 catch (Exception e)
692 {
693 SoapUI.logError( e );
694 return new MessagePart [0];
695 }
696 }
697
698 protected class RequestIconAnimator extends ModelItemIconAnimator implements SubmitListener
699 {
700 public RequestIconAnimator()
701 {
702 super( WsdlRequest.this, "/request.gif",
703 new String[] {"/exec_request_1.gif", "/exec_request_2.gif",
704 "/exec_request_3.gif", "/exec_request_4.gif"} );
705 }
706
707 public boolean beforeSubmit(Submit submit, SubmitContext context)
708 {
709 if( isEnabled() && submit.getRequest() == getTarget() )
710 start();
711 return true;
712 }
713
714 public void afterSubmit(Submit submit, SubmitContext context)
715 {
716 if( submit.getRequest() == getTarget() )
717 stop();
718 }
719 }
720
721 public boolean isMultipartEnabled()
722 {
723 return !getSettings().getBoolean( DISABLE_MULTIPART_ATTACHMENTS );
724 }
725
726 public void setMultipartEnabled( boolean multipartEnabled )
727 {
728 getSettings().setBoolean( DISABLE_MULTIPART_ATTACHMENTS, !multipartEnabled );
729 }
730
731 public String getWssTimeToLive()
732 {
733 return getSettings().getString( WSS_TIMETOLIVE, null );
734 }
735
736 public void setWssTimeToLive( String ttl )
737 {
738 getSettings().setString( WSS_TIMETOLIVE, ttl );
739 }
740
741 @Override
742 public void beforeSave()
743 {
744 if( requestContent != null )
745 {
746 CompressedStringSupport.setString( getConfig().getRequest(), requestContent );
747 requestContent = null;
748 }
749 }
750
751 public long getContentLength()
752 {
753 return getRequestContent().length();
754 }
755
756 public boolean isRemoveEmptyContent()
757 {
758 return getSettings().getBoolean( REMOVE_EMPTY_CONTENT );
759 }
760
761 public void setRemoveEmptyContent( boolean removeEmptyContent )
762 {
763 boolean old = getSettings().getBoolean( REMOVE_EMPTY_CONTENT );
764 getSettings().setBoolean( REMOVE_EMPTY_CONTENT, removeEmptyContent );
765 notifyPropertyChanged( REMOVE_EMPTY_CONTENT, old, removeEmptyContent );
766 }
767
768 public boolean isPrettyPrint()
769 {
770 return getSettings().getBoolean( WsdlSettings.PRETTY_PRINT_RESPONSE_MESSAGES );
771 }
772
773 public void setPrettyPrint( boolean prettyPrint )
774 {
775 boolean old = getSettings().getBoolean( WsdlSettings.PRETTY_PRINT_RESPONSE_MESSAGES );
776 getSettings().setBoolean( WsdlSettings.PRETTY_PRINT_RESPONSE_MESSAGES, prettyPrint );
777 notifyPropertyChanged( WsdlSettings.PRETTY_PRINT_RESPONSE_MESSAGES, old, prettyPrint );
778 }
779
780 public boolean isForceMtom()
781 {
782 return getSettings().getBoolean( FORCE_MTOM );
783 }
784
785 public void setForceMtom( boolean forceMtom )
786 {
787 boolean old = getSettings().getBoolean( FORCE_MTOM );
788 getSettings().setBoolean( FORCE_MTOM, forceMtom );
789 notifyPropertyChanged( FORCE_MTOM, old, forceMtom );
790 }
791
792 public boolean isEncodeAttachments()
793 {
794 return getSettings().getBoolean( ENCODE_ATTACHMENTS );
795 }
796
797 public void setEncodeAttachments( boolean encodeAttachments )
798 {
799 boolean old = getSettings().getBoolean( ENCODE_ATTACHMENTS );
800 getSettings().setBoolean( ENCODE_ATTACHMENTS, encodeAttachments );
801 notifyPropertyChanged( ENCODE_ATTACHMENTS, old, encodeAttachments );
802 }
803
804 public String getBindAddress()
805 {
806 return getSettings().getString( BIND_ADDRESS, "" );
807 }
808
809 public void setBindAddress( String bindAddress )
810 {
811 String old = getSettings().getString( BIND_ADDRESS, "" );
812 getSettings().setString( BIND_ADDRESS, bindAddress );
813 notifyPropertyChanged( BIND_ADDRESS, old, bindAddress );
814 }
815
816 public String getIncomingWss()
817 {
818 return getConfig().getIncomingWss();
819 }
820
821 public void setIncomingWss( String incomingWss )
822 {
823 String old = getIncomingWss();
824 getConfig().setIncomingWss( incomingWss );
825 notifyPropertyChanged( INCOMING_WSS, old, incomingWss );
826 }
827
828 public String getOutgoingWss()
829 {
830 return getConfig().getOutgoingWss();
831 }
832
833 public void setOutgoingWss( String outgoingWss )
834 {
835 String old = getOutgoingWss();
836 getConfig().setOutgoingWss( outgoingWss );
837 notifyPropertyChanged( OUGOING_WSS, old, outgoingWss );
838 }
839
840 public void addAttachmentsChangeListener( PropertyChangeListener listener )
841 {
842 addPropertyChangeListener( ATTACHMENTS_PROPERTY, listener );
843 }
844
845 public boolean isReadOnly()
846 {
847 return false;
848 }
849
850 public void removeAttachmentsChangeListener( PropertyChangeListener listener )
851 {
852 removePropertyChangeListener( ATTACHMENTS_PROPERTY, listener );
853 }
854
855 @SuppressWarnings("unchecked")
856 public List<? extends ModelItem> getChildren()
857 {
858 return Collections.EMPTY_LIST;
859 }
860
861 public PropertyExpansion[] getPropertyExpansions()
862 {
863 List<PropertyExpansion> result = new ArrayList<PropertyExpansion>();
864
865 result.addAll( PropertyExpansionUtils.extractPropertyExpansions( this, this, "requestContent") );
866 result.addAll( PropertyExpansionUtils.extractPropertyExpansions( this, this, "endpoint") );
867 result.addAll( PropertyExpansionUtils.extractPropertyExpansions( this, this, "username") );
868 result.addAll( PropertyExpansionUtils.extractPropertyExpansions( this, this, "password") );
869 result.addAll( PropertyExpansionUtils.extractPropertyExpansions( this, this, "domain") );
870
871 StringToStringMap requestHeaders = getRequestHeaders();
872 for( String key : requestHeaders.keySet())
873 {
874 PropertyExpansionUtils.extractPropertyExpansions( this, new RequestHeaderHolder( requestHeaders, key ), "value" );
875 }
876
877 return result.toArray( new PropertyExpansion[result.size()] );
878 }
879
880 private class RequestHeaderHolder
881 {
882 private final StringToStringMap valueMap;
883 private final String key;
884
885 public RequestHeaderHolder( StringToStringMap valueMap, String key )
886 {
887 this.valueMap = valueMap;
888 this.key = key;
889 }
890
891 public String getValue()
892 {
893 return valueMap.get( key );
894 }
895
896 public void setValue( String value )
897 {
898 valueMap.put( key, value );
899 setRequestHeaders( valueMap );
900 }
901 }
902
903
904
905
906
907 }