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