1
2
3
4
5
6
7
8
9
10
11
12
13 package com.eviware.soapui.impl.wsdl.support.soap;
14
15 import java.io.IOException;
16
17 import javax.xml.namespace.QName;
18
19 import org.apache.xmlbeans.SchemaType;
20 import org.apache.xmlbeans.SchemaTypeLoader;
21 import org.apache.xmlbeans.XmlBeans;
22 import org.apache.xmlbeans.XmlException;
23 import org.apache.xmlbeans.XmlObject;
24 import org.w3.x2003.x05.soapEnvelope.EnvelopeDocument;
25 import org.w3.x2003.x05.soapEnvelope.FaultDocument;
26
27 import com.eviware.soapui.SoapUI;
28 import com.eviware.soapui.impl.wsdl.support.Constants;
29
30 /***
31 * SoapVersion for SOAP 1.2
32 *
33 * @author ole.matzura
34 */
35
36 public class SoapVersion12 extends AbstractSoapVersion
37 {
38 private final static QName envelopeQName = new QName(Constants.SOAP12_ENVELOPE_NS, "Envelope");
39 private final static QName bodyQName = new QName(Constants.SOAP12_ENVELOPE_NS, "Body");
40 private final static QName faultQName = new QName(Constants.SOAP11_ENVELOPE_NS, "Fault");
41 private final static QName headerQName = new QName(Constants.SOAP12_ENVELOPE_NS, "Header");
42 public final static SoapVersion12 instance = new SoapVersion12();
43
44 private SchemaTypeLoader soapSchema;
45 private XmlObject soapSchemaXml;
46 private XmlObject soapEncodingXml;
47
48 private SoapVersion12()
49 {
50 ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
51 Thread.currentThread().setContextClassLoader( SoapUI.class.getClassLoader() );
52
53 try
54 {
55 soapSchemaXml = XmlObject.Factory.parse(SoapUI.class.getResource("/soapEnvelope12.xsd"));
56 soapSchema = XmlBeans.loadXsd(new XmlObject[] { soapSchemaXml });
57 soapEncodingXml = XmlObject.Factory.parse(SoapUI.class.getResource("/soapEncoding12.xsd"));
58 }
59 catch( Exception e )
60 {
61 SoapUI.logError( e );
62 }
63 finally
64 {
65 Thread.currentThread().setContextClassLoader( contextClassLoader );
66 }
67 }
68
69 public String getEncodingNamespace()
70 {
71 return "http://www.w3.org/2003/05/soap-encoding";
72 }
73
74 public XmlObject getSoapEncodingSchema() throws XmlException, IOException
75 {
76 return soapEncodingXml;
77 }
78
79 public XmlObject getSoapEnvelopeSchema() throws XmlException, IOException
80 {
81 return soapSchemaXml;
82 }
83
84 public String getEnvelopeNamespace()
85 {
86 return Constants.SOAP12_ENVELOPE_NS;
87 }
88
89 public SchemaType getEnvelopeType()
90 {
91 return EnvelopeDocument.type;
92 }
93
94 public String toString()
95 {
96 return "SOAP 1.2";
97 }
98
99 public String getContentTypeHttpHeader(String encoding, String soapAction)
100 {
101 String result = getContentType();
102
103 if (encoding != null && encoding.trim().length() > 0)
104 result += ";charset=" + encoding;
105
106 if( soapAction != null )
107 result += ";action=" + soapAction;
108
109 return result;
110 }
111
112 public String getSoapActionHeader( String soapAction )
113 {
114
115 return null;
116 }
117
118 public String getContentType()
119 {
120 return "application/soap+xml";
121 }
122
123 public QName getBodyQName()
124 {
125 return bodyQName;
126 }
127
128 public QName getEnvelopeQName()
129 {
130 return envelopeQName;
131 }
132
133 public QName getHeaderQName()
134 {
135 return headerQName;
136 }
137
138 protected SchemaTypeLoader getSoapEnvelopeSchemaLoader()
139 {
140 return soapSchema;
141 }
142
143 public static QName getFaultQName()
144 {
145 return faultQName;
146 }
147
148 public SchemaType getFaultType()
149 {
150 return FaultDocument.type;
151 }
152
153 public String getName()
154 {
155 return "SOAP 1.2";
156 }
157 }