View Javadoc

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