View Javadoc

1   /*
2    *  soapUI, copyright (C) 2006 eviware.com 
3    *
4    *  soapUI is free software; you can redistribute it and/or modify it under the 
5    *  terms of the GNU Lesser General Public License as published by the Free Software Foundation; 
6    *  either version 2.1 of the License, or (at your option) any later version.
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.panels.request.components;
14  
15  import java.beans.PropertyChangeEvent;
16  import java.beans.PropertyChangeListener;
17  
18  import org.apache.xmlbeans.SchemaTypeSystem;
19  import org.apache.xmlbeans.XmlBeans;
20  
21  import com.eviware.soapui.impl.wsdl.WsdlInterface;
22  import com.eviware.soapui.impl.wsdl.WsdlRequest;
23  import com.eviware.soapui.impl.wsdl.panels.request.components.editor.support.AbstractXmlDocument;
24  import com.eviware.soapui.impl.wsdl.support.wsdl.WsdlContext;
25  
26  public class RequestXmlDocument extends AbstractXmlDocument implements PropertyChangeListener
27  {
28  	private final WsdlRequest request;
29  	private boolean updating;
30  
31  	public RequestXmlDocument(WsdlRequest request)
32  	{
33  		this.request = request;
34  		request.addPropertyChangeListener( WsdlRequest.REQUEST_PROPERTY, this );
35  	}
36  
37  	public String getXml()
38  	{
39  		return request.getRequestContent();
40  	}
41  
42  	public void setXml(String xml)
43  	{
44  		request.setRequestContent( xml );
45  	}
46  
47  	public void propertyChange(PropertyChangeEvent evt)
48  	{
49  		if( !updating )
50  			fireXmlChanged( (String)evt.getOldValue(), (String)evt.getNewValue() );
51  	}
52  
53  	public SchemaTypeSystem getTypeSystem()
54  	{
55  		WsdlInterface iface = (WsdlInterface) request.getOperation().getInterface();
56  		WsdlContext wsdlContext = iface.getWsdlContext();
57  		try
58  		{
59  			return wsdlContext.getSchemaTypeSystem();
60  		}
61  		catch (Exception e1)
62  		{
63  			e1.printStackTrace();
64  			return XmlBeans.getBuiltinTypeSystem();
65  		}
66  	}
67  }