01: /*
02: * soapUI, copyright (C) 2004-2007 eviware.com
03: *
04: * soapUI is free software; you can redistribute it and/or modify it under the
05: * terms of version 2.1 of the GNU Lesser General Public License as published by
06: * the Free Software Foundation.
07: *
08: * soapUI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
09: * 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.mockoperation;
14:
15: import org.apache.xmlbeans.SchemaTypeSystem;
16: import org.apache.xmlbeans.XmlBeans;
17:
18: import com.eviware.soapui.SoapUI;
19: import com.eviware.soapui.impl.wsdl.WsdlInterface;
20: import com.eviware.soapui.impl.wsdl.WsdlOperation;
21: import com.eviware.soapui.impl.wsdl.mock.WsdlMockResponse;
22: import com.eviware.soapui.impl.wsdl.mock.WsdlMockResult;
23: import com.eviware.soapui.impl.wsdl.panels.request.components.editor.XmlDocument;
24: import com.eviware.soapui.impl.wsdl.panels.request.components.editor.support.AbstractXmlDocument;
25: import com.eviware.soapui.impl.wsdl.support.wsdl.WsdlContext;
26:
27: /**
28: * XmlDocument for the last request to a WsdlMockResponse
29: *
30: * @author ole.matzura
31: */
32:
33: public class MockRequestXmlDocument extends AbstractXmlDocument
34: implements XmlDocument {
35: private final WsdlMockResponse mockResponse;
36:
37: public MockRequestXmlDocument(WsdlMockResponse response) {
38: this .mockResponse = response;
39: }
40:
41: public SchemaTypeSystem getTypeSystem() {
42: try {
43: WsdlOperation operation = mockResponse.getMockOperation()
44: .getOperation();
45: if (operation != null) {
46: WsdlInterface iface = operation.getInterface();
47: WsdlContext wsdlContext = iface.getWsdlContext();
48: return wsdlContext.getSchemaTypeSystem();
49: }
50: } catch (Exception e1) {
51: SoapUI.logError(e1);
52: }
53:
54: return XmlBeans.getBuiltinTypeSystem();
55: }
56:
57: public String getXml() {
58: WsdlMockResult mockResult = mockResponse.getMockResult();
59: return mockResult == null ? null : mockResult.getMockRequest()
60: .getRequestContent();
61: }
62:
63: public void setXml(String xml) {
64: WsdlMockResult mockResult = mockResponse.getMockResult();
65: if (mockResult != null) {
66: String oldXml = getXml();
67: mockResult.getMockRequest().setRequestContent(xml);
68: oldXml = "";
69: fireXmlChanged(oldXml, xml);
70: }
71: }
72: }
|