View Javadoc

1   /*
2    *  soapUI, copyright (C) 2004-2009 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.support;
14  
15  import javax.wsdl.BindingOperation;
16  import javax.wsdl.Part;
17  
18  import org.apache.xmlbeans.SchemaType;
19  import org.apache.xmlbeans.XmlCursor;
20  import org.apache.xmlbeans.XmlObject;
21  
22  import com.eviware.soapui.impl.wsdl.support.wsdl.WsdlUtils;
23  
24  /***
25   * Wrapper for WSDL parts
26   * 
27   * @author ole.matzura
28   */
29  
30  public class MessageXmlPart
31  {
32  	private XmlObject partXmlObject;
33  	private final XmlObject sourceXmlObject;
34  	private final Part part;
35  	private final BindingOperation bindingOperation;
36  	private final boolean isRequest;
37  
38  	public MessageXmlPart( XmlObject sourceXmlObject, SchemaType type, Part part, BindingOperation bindingOperation,
39  			boolean isRequest )
40  	{
41  		this.sourceXmlObject = sourceXmlObject;
42  		this.part = part;
43  		this.bindingOperation = bindingOperation;
44  		this.isRequest = isRequest;
45  		partXmlObject = type == null ? sourceXmlObject.copy() : sourceXmlObject.copy().changeType( type );
46  	}
47  
48  	public void update()
49  	{
50  		sourceXmlObject.set( partXmlObject );
51  	}
52  
53  	public XmlCursor newCursor()
54  	{
55  		return partXmlObject.newCursor();
56  	}
57  
58  	public boolean isAttachmentPart()
59  	{
60  		return isRequest ? WsdlUtils.isAttachmentInputPart( part, bindingOperation ) : WsdlUtils.isAttachmentOutputPart(
61  				part, bindingOperation );
62  	}
63  
64  	public Part getPart()
65  	{
66  		return part;
67  	}
68  }