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.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, boolean isRequest)
39  	{
40  		this.sourceXmlObject = sourceXmlObject;
41  		this.part = part;
42  		this.bindingOperation = bindingOperation;
43  		this.isRequest = isRequest;
44  		partXmlObject = type == null ? sourceXmlObject.copy() : sourceXmlObject.copy().changeType( type );
45  	}
46  
47  	public void update()
48  	{
49  		sourceXmlObject.set( partXmlObject );
50  	}
51  
52  	public XmlCursor newCursor()
53  	{
54  		return partXmlObject.newCursor();
55  	}
56  
57  	public boolean isAttachmentPart()
58  	{
59  		return isRequest ? WsdlUtils.isAttachmentInputPart( part, bindingOperation ) : 
60  			WsdlUtils.isAttachmentOutputPart( part, bindingOperation );
61  	}
62  
63  	public Part getPart()
64  	{
65  		return part;
66  	}
67  }